bsd-games-2.17/0000775000175000017500000000000010205246626012002 5ustar jsm28jsm28bsd-games-2.17/quiz/0000775000175000017500000000000010205246604012766 5ustar jsm28jsm28bsd-games-2.17/quiz/datfiles/0000775000175000017500000000000010205246604014561 5ustar jsm28jsm28bsd-games-2.17/quiz/datfiles/collectives0000664000175000017500000000321607343203043017021 0ustar jsm28jsm28actors|soldiers:company angels:host ants:colony|hill apes:shrewdness asses:pace|bunch badgers:cete bass:shoal bears:sloth bees:swarm bees|locusts:swarm birds:dissimulation brats:passel buffaloes:herd candidates:slate caterpillars:army cats:clowder cattle:drove|herd chickens:peep|flock crows:murder curs:cowardice dogs:pack doves:dule ducks:[pad|ba]dling earthquakes:swarm eggs:clutch elephants:herd elk:gang engineers:corps ferrets:business finches:charm firemen:brigade fish:school foxes:skulk gangsters:mob geese in flight:skein geese on water:gaggle goats:trip grapes|bananas:bunch hawks:cast hens:brood herons:siege horses:haras|team hounds:kennel jellyfish:smack kangaroos|monkeys:troop kittens:kindle lapwings:deceit larks:exaltation|bevy leopards:leap lions:pride locusts:plague magpies:tidings maidens|quail:bevy martens:richness men:band moles:labor monkeys|kangaroos:troop mountains:range mules:barren|baren nightingales:watch operating companies:at&t|bell system owls:parliament oxen:drove partridges:covey partridges|grouse:covey peacocks:ostentation people:crowd pheasants:bouquet plovers:congregation ponies:string porpoises:shoal prisoners:gang pups:litter quail|maidens:bevy rabbits:nest ravens:unkindness rhinoceroses:crash robbers:band roebucks:bevy rooks:building rubbish:heap seals:pod sheep:flock ships:fleet snipe:walk|wisp sparrows:host squirrels:dray starlings:murmuration stars:constellation storks:mustering swallows:flight teal:spring toads:knot turkeys:rafter turtledoves:pitying whales:gam|pod whales|fish:school witches:coven wolves:pack wolves:route woodcocks:fall woodpeckers:descent worshippers:congregation {H|h}uns:horde {wild }swine:sounder bsd-games-2.17/quiz/datfiles/latin0000664000175000017500000000561406363445554015640 0ustar jsm28jsm28condo:{I }found condidi:{I }founded laedo:{I }[injure|thwart] impello:{I }[drive|force] impulit:{he }[drove|forced] sino:{I }permit sinat:{he }permit{s} dolor:pain|grief invideo:{I }[envy|hate] invisus:[hated|envied] immitis:cruel|harsh arceo:{I }[keep away|hinder|prevent] ratis:ship antrum:cave freno:rein{ in}|curb|check celsus:lofty spelunca:cave{rn} foedus (n.):agreement|treaty|truce foedera:agreements|treaties laxus:loose|free habena:rein{s} mulceo:soothe|calm fluctus (n.):wave{s} exigo:finish|spend exegit:{he }[finished|spent] opto (v.):desire|wish optat:{he }[desire{s}|wish{es}] capesso:seize|carry out concilio (v.):secure|gain converto:reverse procella:blast|gust polus:sky|heaven mico:flash|gleam extemplo:immediately frigus (n.):cold|chill ingemo:groan os (n.):mouth effundo:pour{ out} corripio:snatch|catch harena:sand excutio:shake{ off} nare:{to }swim rima:crack|fissure fatisco:gape{ open} disjicio:scatter|disperse dolus (n.):deceit luo:wash{ away}|atone{ for} cito (adv.):quickly|soon tumidus:swollen fugo:put to flight|drive out adnitor:strive seditio:riot|uprising fax:fire{-}brand volo (v.):fly arrigo:prick up cunctus:whole|entire flecto:turn|guide sinus:bay|fold|curve|gulf scindo:split|divide rupes:crag|cliff geminus:twin minatur:{he }threaten{s} coruscus:flashing|waving horreo:bristle nemus:grove nemora:groves umbra:shade|shadow intus:within dulcis:sweet|fresh sedile:seat|bench fessus:weary|tired uncus:hooked|curved morsus:bite artus:joint|limb silex:flint scintilla:spark folium:leaf aridus:dry corrumpo:spoil|ruin corrupit:{he }[spoil{ed}|ruin{ed}] frux:grain torreo:parch celsus:high|lofty cervus:stag erro:wander armentum:herd pasco:feed|nourish pascor:graze arcus:bow turba:crowd sterno:strew humus:ground|earth vinum:wine maereo:mourn|sorrow ignarus:unknowing|ignorant|inexperienced rabies:rage|fury penitus:within sono (v.):sound|roar maestus:sad|gloomy forsan:perhaps olim:someday|sometime memini:{I }remember varius:different discrimen:crisis|danger quiesco:become quiet refert:{he }[say{s}|tell{s}] vultus:face|countenance cor:heart corda:hearts dolor:pain|grief daps:feast dapes:feasts viscus:flesh seco:cut tremo:quiver pinguis:fat|rich mensa:table sermo:talk|discourse dubius:doubtful|wavering pius:dutiful|devoted|loyal gemo:lament|moan|bemoan crudelis:cruel|bitter lumen:light|eye lumina:lights|eyes tristis:sad lacrima:tear niteo:shine|glisten fulmen:thunderbolt|lightning fulmina:thunderbolts funus:death|disaster funera:deaths|disasters orbis terrarum:world ductor:leader dicio (n.):power fons:spring|source fontes:springs|sources arvum:land infandus:unspeakable rideo:laugh osculum:lip libo:sip|touch|kiss nata:daughter haereo:{I }[stick to|adhere] promitto:primise sublimis:high|uplifted|up high quando:since|when|because arcanum:{a }secret ferox:fierce|savage contundo:crush albus:white donec:until sacerdos:priest{ess} lupus:wolf nutrix:nurse nutrices:nurses fulvus:tawny|yellow meta:limit|boundary bsd-games-2.17/quiz/datfiles/trek0000664000175000017500000000204606363445554015472 0ustar jsm28jsm28captain's name:{James |Jim }{T. }Kirk|{james |jim }{t. }kirk first officers name:Spock|spock|Mr. Spock|mr. spock name of ship:{the }{u.s.s. }enterprise|Enterprise name of the "good guys":{the }Federation|federation|{the }federation name of the "bad guys":{the }klingons|{the }romulans nickname of chief engineer:scotty|Scotty nickname of chief medical officer:bones|Bones machine used for transportation to surface of nearby planet:transporter|shuttlecraft main engines of ship:warp engines|warp number of crew:400|four hundred hand-held weapon:phaser type of torpedoes used on the ship:photon torpedoes|photon name of electronic protective device on ship:shields|shield name of device that makes a ship invisible:cloaking device|cloak|cloaking type of voice that the on-board computer has:female|feminine|woman's where first officer comes from:vulcan|Vulcan rare, but very powerful enemies:romulans|Romulans reaction that main engines operate on:matter-antimatter{ reaction}|matter/antimatter{ reaction} slow engines used in emergencies:impulse engines|impulse bsd-games-2.17/quiz/datfiles/locomotive0000664000175000017500000000233606363445554016707 0ustar jsm28jsm280-4-0:Four[-| ]Coupled 0-6-0:Six[-| ]Coupled 0-8-0:Eight[-| ]Coupled 0-10-0:Ten[-| ]Coupled 2-2-2:Single 2-6-2:Prairie 2-6-6-6:Allegheny|Blue Ridge 2-8-0:Consol{idation} 2-8-2:Mik[ado|e] 2-8-4:Berk{shire}|Kanawha 2-8-4:Kanawha|Berk{shire} 2-8-8-2:Chesapeake 2-8-8-4:Yellowstone 2-8-8-8-2|2-8-8-4:Triplex 2-10-0|2-10-2:Decapod 2-10-2:Santa Fe|Central|Decapod 2-10-4:Texas|Selkirk|Colorado 2-10-4:Selkirk|Texas|Colorado 4-2-0:Six[- | ]Wheeler 4-2-2:Bicycle 4-4-0:American|Eight[-| ]Wheeler 4-4-0:Eight[-| ]Wheeler|American 4-4-2:Atlantic|Chautauqua 4-4-4:Jubilee|Reading 4-6-0:Ten[-| ]Wheeler 4-6-2:Pacific 4-6-4:Hudson|Baltic|Shore Line 4-6-4:Baltic|Hudson|Shore Line 4-6-6-4:Challenger 4-8-0:Twelve[-| ]Wheeler|Mastodon 4-8-2:Mountain|Mohawk 4-8-2:Mohawk|Mountain 4-8-4:Northern|Confederation|Dixie|Golden State|Greenbriar|Montana|Niagara|Pocono|Potomac|Wyoming 4-8-4:Niagara|Northern|Confederation|Dixie|Golden State|Greenbriar|Montana|Pocono|Potomac|Wyoming 4-8-4:Greenbriar|Niagara|Northern|Confederation|Dixie|Golden State|Montana|Pocono|Potomac|Wyoming 4-8-4:Pocono|Greenbriar|Niagara|Northern|Confederation|Dixie|Golden State|Montana|Potomac|Wyoming 4-8-8-4:Big Boy 4-[10|8]-0:Mastodon 4-10-2:Southern Pacific|Overland 4-12-2:Union Pacific bsd-games-2.17/quiz/datfiles/poetry0000664000175000017500000001351706363445554016054 0ustar jsm28jsm28Come live with me and be my love:\ And we will all the pleasures prove:\ {The }Passionate Shepherd{ to his Love}:\ {Christopher }Marlowe Shall I compare thee to a summer's day{?}:\ Thou art more lovely and more temperate:\ Sonnet 18:\ {William }Shakespeare Fine knacks for ladies, cheap, choice, brave, and new!:\ Good pennyworths{! }but money cannot move:\ Fine Knacks{ for Ladies}:\ {John }Dowland My mind to me a kingdom is:\ Such perfect joy therein I find:\ My Mind to Me a Kingdom Is:\ {Sir }{Edward }Dyer Underneath this stone doth lie:\ As much beauty as could die:\ Epitaph on Elizabeth{,} {L. H.}:\ {Ben }Jonson Death be not proud, though some have called thee:\ Mighty and dreadful{,} for thou art not so:\ {Holy }Sonnet{s}{ 10}:\ {John }Donne Gather ye rose-buds while ye may:\ Old Time is still a-flying:\ To the Virgins{,} {To Make Much of Time}:\ {Robert }Herrick Why so pale and wan, fond lover?:\ Prithee{,} why so pale{?}:\ Song:\ {Sir }{John }Suckling Stone walls do not a prison make:\ Nor iron bars a cage:\ To Althea{,} From Prison:\ {Richard }Lovelace I could not love thee (Dear) so much,:\ Lov['|e]d I not hono{u}r more:\ To Lucasta{, Going to the Wars}:\ {Richard }Lovelace I saw Eternity the other night:\ Like a great ring of pure and endless light:\ {The }World:\ {Henry }Vaughan Come and trip it as you go,:\ On the light fantastic toe:\ L'Allegro:\ {John }Milton When I consider how my light is spent:\ Ere half my days in this dark world and wide:\ On His Blindness|When I Consider:\ {John }Milton The grave's a fine and private place{,}:\ But none{,} I think{,} do there embrace{.}:\ To His Coy Mistress:\ {Andrew }Marvel Great wits are sure to madness near allied:\ And thin partitions do their bounds divide:\ Absalom and Achitophel|Absalom:\ {John }Dryden A little learning is a dangerous thing{;}:\ Drink deep{,} or taste not the Pierian spring{.}:\ {An }Essay on Criticism|{On }Criticism:\ {Alexander }Pope The curfew tolls the knell of parting day{,}:\ The lowing herd wind slowly o'er the lea:\ Elegy{ Written in a Country Church{-| }Yard:\ {Thomas }Gray The best laid schemes o' mice an' men gang aft a-gley{,}:\ An{'|d} lea{'|v}e us nought but grief an{'|d} pain for promised joy{.}:\ To a Mouse:\ {Robert }Burns Tiger! tiger! burning bright!:\ In the forests of the night:\ {The }Tiger:\ {William }Blake My heart leaps up when I behold:\ A rainbow in the sky:\ My Heart Leaps Up:\ {William }Wordsworth The world is too much with us; late and soon{,}:\ Getting and spending{,} we lay waste our powers:\ {The }World is Too Much With Us|Sonnet:\ {William }Wordsworth A sadder and a wiser man{,}:\ He rose the morrow morn:\ {The }{Rime of }{The }Ancient Mariner:\ {Samuel }{Taylor }Coleridge In Xanadu did Kubla Khan:\ A stately pleasure{-| }dome decree:\ Kubla Khan:\ {Samuel }{Taylor }Coleridge She walks in beauty, like the night:\ Of cloudless climes and starry skies:\ She Walks in Beauty:\ {George Gordon, }{Lord }Byron I want a hero- an uncommon want{,}:\ When every year and month sends forth a new one:\ Don Juan{ Canto I}:\ {George Gordon, }{Lord }Byron A thing of beauty is a joy forever.:\ Its loveliness increases{;|.} {it will never/Pass into nothingness}:\ Endymion{ Book I}:\ {John }Keats Matched with an aged wife, I mete and dole:\ Unequal laws unto a savage race:\ Ulysses:\ {Alfred{,} }{Lord }Tennyson He will hold thee, when his passion shall have spent its novel force{,}:\ Something better than his dog{,} a little dearer than his horse:\ Locksley Hall:\ {Alfred{,} }{Lord }Tennyson 'Tis better to have loved and lost:\ Than never to have loved at all:\ {In }Memoriam{ A. H. H.}:\ {Alfred{,} }{Lord }Tennyson Kind hearts are more than coronets,:\ And simple faith than Norman blood{.}:\ Lady Clara Vere de Vere:\ {Alfred{,} }{Lord }Tennyson Oh, to be in England:\ Now that April's there:\ Home{-| }Thoughts{,} From Abroad:\ {Robert }Browning Ah, but a man's reach should exceed his grasp{,}:\ Or what's a heaven for{?}:\ Andrea Del Sarto:\ {Robert }Browning How do I love thee? Let me count the ways.:\ I love thee to the depth and breadth and height:\ Sonnet{s} {From the Portuguese}{ 43}:\ {Elizabeth }{Barrett }Browning A Book of Verses underneath the Bough{,}:\ A Jug of Wine, a Loaf of Bread{-|,| }and Thou:\ {The }Rubaiyat{ of Omar Khayyam}{ 12}:\ {Edward }Fitzgerald The Moving Finger writes; and, having writ,:\ Moves on{\:|,|.} nor all your Piety nor Wit:\ {The }Rubaiyat{ of Omar Khayyam}{ 71}:\ {Edward }Fitzgerald Ah Love! could you and I with Him conspire:\ To grasp this sorry Scheme of Things entire:\ {The }Rubaiyat{ of Omar Khayyam}{ 99}:\ {Edward }Fitzgerald Remember me when I am gone away,:\ Gone far away into the silent land:\ Remember:\ {Christina }Rossetti Home is the sailor, home from the sea,:\ And the hunter home from the hill:\ Requiem:\ {Robert }{Louis }Stevenson I fled Him, down the nights and down the days;:\ I fled Him, down the arches of the years:\ {The }Hound of Heaven:\ {Francis }Thompson So 'ere's to you, Fuzzy-Wuzzy, at your 'ome in the Soudan;:\ You're a {pore|poor} benighted {'|h}eathen but a first class fightin{'|g} man:\ Fuzzy{-| }Wuzzy:\ {Rudyard }Kipling Morns abed and daylight slumber:\ Were not meant for man alive:\ Reveille:\ {A{.}{ }E{.}{ }}Houseman I will arise and go now, and go to Innisfree,:\ And a small cabin build there{,} of clay and wattles made:\ {The }{Lake Isle of }Innisfree:\ {William }{Butler }Yeats I must go down to the seas again, to the lonely sea and the sky,:\ And all I ask is a tall ship and a star to steer her by:\ Sea{-| }Fever:\ {John }Masefield April is the cruelest month, breeding:\ Lilacs out of the dead land:\ {The }Waste{ }Land:\ {T{.}{ }S{.}{ }}Eliot Now as I was young and easy under the apple boughs:\ About the little house and happy as the grass was green:\ Fern Hill:\ {Dylan }Thomas Of Man's first disobedience, and the fruit:\ Of that forbidden tree{,} whose mortal taste:\ Paradise Lost:\ {John }Milton bsd-games-2.17/quiz/datfiles/province0000664000175000017500000000047206363445554016353 0ustar jsm28jsm28Newfoundland{ and Labrador}:[St.|Saint] John's New Brunswick:Fredericton Prince Edward Island:Charlottetown Nova Scotia:Halifax Quebec:Quebec Ontario:Toronto Manitoba:Winnipeg Saskatchewan:Regina Alberta:Edmonton British Columbia:Victoria Yukon Territory:Whitehorse Northwest Territories:Yellowknife Canada:Ottawa bsd-games-2.17/quiz/datfiles/babies0000664000175000017500000000062106363445554015747 0ustar jsm28jsm28cub:lion|tiger|bear kitten:cat|fox|skunk|rabbit|bobcat|panther gosling:goose colt|foal:horse|donkey|zebra puppy:dog pup:seal|fox|beaver duckling:duck fawn:deer piglet|shoat:pig lamb:sheep kid:goat|antelope chick:chicken tadpole|polliwog:frog|toad joey:kangaroo calf:cow|whale|moose|elephant|buffalo|giraffe caterpillar:butterfly|moth elver:eel eaglet:eagle owlet:owl fingerling|fry:fish nestling:bird bsd-games-2.17/quiz/datfiles/posneg0000664000175000017500000000145107641024615016006 0ustar jsm28jsm28large|big:small on:off standing up:sitting down inside:outside high:low old:new|young hot:cold out:in heavy|dark:light daytime:night[time| time] stop|come:go top:bottom floor:ceiling near:far run:walk empty|hungry:full backwards:f[or|ront]wards big|large:little|small fat|thick:thin|skinny bright|light:dark|dull right:wrong|left give:take|receive|get buy:sell shiny|bright:dull dawn:dusk fall down|go to bed:[get|stand|rise] up asleep:awake up:down open[ed|]:close[d|] smile:frown|cry happy|glad:sad hard:soft|easy boy|woman|lady:girl|man fast:slow wet:dry covered|hid[den|]:uncovered|open good:bad always|sometimes|now:never|sometimes beautiful|pretty:ugly rough:smooth hairy:bald|smooth above:below yin:yang sweet:sour if:unless from|fro:to with[in|]:without|against after:before together:apart plus:minus bsd-games-2.17/quiz/datfiles/midearth0000664000175000017500000000041707240362720016306 0ustar jsm28jsm28Shire:Michel Delving|Hobbiton Mordor:Barad Dur Gondor:Minas Tirith Umbar:{City of the }Corsairs Rhovanion:Esgaroth{ upon the Long Lake} Rohan:Edoras Lothl['o|o|o']rien:Caras Galadon Breeland:Bree Arnor:Ann['u|u'|u]minas Arthedain:Fornost{ Erain}|Norbury of the Kings bsd-games-2.17/quiz/datfiles/america0000664000175000017500000000104406363445554016123 0ustar jsm28jsm28Argentina:Buenos Aires Bahamas:Nassau Barbados:Bridgetown Bolivia:La Paz|Sucre Bra[z|s]il:Brasilia Canada:Ottawa Chile:Santiago Colombia:Bogot['a|a'|a] Costa Rica:San Jose Cuba:Ha[v|b]ana Dominican Republic:Santo Domingo Ecuador:Quito El Salvador:San Salvador Guatemala:Guatemala Guyana:Georgetown Haiti:Port au Prince Honduras:Tegucigalpa Jamaica:Kingston Mexico:Mexico Nicaragua:Managua Panama:Panama Paraguay:Asunci['o|o'|o]n Peru:Lima Trinidad[ and Tobago|]:Port of Spain United States|US{A}:Washington Uruguay:Montevideo Venezuela:Caracas bsd-games-2.17/quiz/datfiles/seq-hard0000664000175000017500000000155006363445554016230 0ustar jsm28jsm281,1,2,1,2,2,3,1,2,2,3,2,3,3,4:1{(1's in binary nos)}:number of 1's in binary numbers 1,1,2,2,4,2,6,4,6,4,10:4{(phi(n))}:Euler's [totient|phi]{ function}|phi(n) 1,2,2,4,2,4,2,4,6,2:6{(diff of primes)}:diff{erences} [between|of] primes 1,2,4,11,34:156{(unlabeled graphs)}:{unlabeled }graphs 1,2,5,14,42,132:429{(Catalan)}:Catalan{ numbers} 1,2,5,16,61:272{(Euler)}:Euler{ numbers} 1,3,12,60,360:2520{(n!/2)}:Even permutations|n!/2 1,3,16,125,1296,16807:262144{(n**(n-2))}:{labeled }trees|n[**|^](n-2) 1,4,10,20,35,56:84{(C(n,3))}:Tetrahedral{ numbers}|C(n,3) 1,4,11,20,31,44,61:100{(n**2 base 8)}:[Squares|n[**|^]2} base 8|octal squares 1,4,16,256:65536{(2**2**n)}:{labeled }boolean functions|2[**|^]2[**|^]n 1,6,28:496{(perfect nos)}:perfect{ numbers} 2,7,1,8,2,8:1{(e)}:{digits of }e 3,1,4,1,5,9:2{(pi)}:{digits of }pi 3,7,31,127:8191{(Mersenne primes)}:Mersenne{ primes} bsd-games-2.17/quiz/datfiles/index.in0000664000175000017500000000250006767673067016246 0ustar jsm28jsm28@quiz_dir@/africa:Africa{n}:cap{ital} @quiz_dir@/america:America{n}:cap{ital} @quiz_dir@/areas:area{-code}:state{-region}:city @quiz_dir@/arith:arith{metic}:ans{wer} @quiz_dir@/asia:Asia{n}:cap{ital} @quiz_dir@/babies:baby:adult @quiz_dir@/bard:Shakespeare{{-}line{s}}|line{s}:next:work:char{acter} @quiz_dir@/chinese:{Chinese{-}}year:next @quiz_dir@/collectives:ind{ividuals}:coll{ective} @quiz_dir@/ed:function:ed-command @quiz_dir@/elements:symbol:number:weight:element @quiz_dir@/europe:Europe{an}:cap{ital} @quiz_dir@/flowers:flower{s}:meaning @quiz_dir@/greek:greek:english @quiz_dir@/inca:inca:succ{essor} @quiz_dir@/latin:latin:english @quiz_dir@/locomotive:locomotive:name @quiz_dir@/midearth:M[iddle{-}Earth|E]:cap{ital} @quiz_dir@/morse:clear|alpha{bet{ic}}:morse @quiz_dir@/mult:mult{iplication}:ans{wer} @quiz_dir@/murders:victim:killer @quiz_dir@/poetry:poem{-}line:next:poem:author @quiz_dir@/posneg:pos{itive}:neg{ative} @quiz_dir@/pres:pres{ident}:term:vice:succ{essor} @quiz_dir@/province:province:cap{ital} @quiz_dir@/seq-easy:easy{-}{seq{uence}}:next:name @quiz_dir@/seq-hard:hard{-}{seq{uence}}:next:name @quiz_dir@/sexes:male:female @quiz_dir@/sov:sov{ereign}:cen{t{ury}}:succ{essor} @quiz_dir@/state:state:cap{ital}:abbr{ev{iation}}:flower @quiz_dir@/trek:star:trek @quiz_dir@/ucc:section:U{niform{-}}C{riminal{-}}C{ode} bsd-games-2.17/quiz/datfiles/arith0000664000175000017500000000142506363445554015634 0ustar jsm28jsm2863 - ... = 55:8 147 - 3 = ...:144 614 - 9 ...:605 465 - 7 = ...:458 563 - ... = 560:3 33 - 14 = ...:19 42 - ... = 37:5 264 - 3 = ...:261 763 - 8 = ...:755 375 - 6 = ...:369 736 - ... = 728:8 62 - 34 = ...:28 75 - 8 = ...:67 244 - ... = 230:14 478 - 19 = ...:459 78 - ... = 75:3 679 - 5 = ...:674 564 - 7 = ...:557 761 - 5 = ...:756 718 - ... = 716:2 56 - 18 = ...:38 65 - ... = 48:17 748 - 5 = ...:743 856 - 8 = ...:848 763 - 5 = ...:758 445 - ... = 436:9 94 - 55 = ...:39 42 - 9 = ...:33 483 - ... = 455:28 742 - ... = 714:28 84 - ... = 75:9 569 - 7 = ...:562 856 - 7 = ...:849 324 - 6 = ...:318 437 - ... = 432:5 84 - 56 = ...:28 81 - ... = 65:16 326 - 4 = ...:322 643 - 7 = ...:636 546 - 9 = ...:537 842 - ... = 835:7 53 - 39 = ...:14 63 - 48 = ...:15 57 - 38 = ...:19 52 - 26 = ...:26 bsd-games-2.17/quiz/datfiles/bard0000664000175000017500000001530606363445554015440 0ustar jsm28jsm28The quality of mercy is not strain['|e]d:\ It droppeth as the gentle rain from heaven:\ {The }Merchant{ of Venice{ IV-i}}:\ Portia Friends{,} Romans{,} Countrymen:\ lend me your ears{;}:\ {Julius }Caesar{ III-ii}:\ {Mark }Antony Neither a borrower nor a lender be:\ For loan oft loses both itself and friend{.}:\ Hamlet{ I-iii}:\ Polonius To be{,} or not to be{\:}:\ that is the question{\:}:\ Hamlet{ III-i}:\ Hamlet Alas{,} poor Yorick{!}:\ I knew him{,} Horatio{;}:\ Hamlet{ V-i}:\ Hamlet Double{,} double toil and trouble{;}:\ Fire burn and cauldron bubble{.}:\ Macbeth{ IV-i}:\ Witch{es} By the pricking of my thumbs{,}:\ Something wicked this way comes{.}:\ Macbeth{ IV-i}:\ {Second |2nd }Witch Out, damned spot! out, I say!:\ :\ Macbeth{ V-i}:\ Lady Macbeth Unbidden guests:\ Are often welcomest when they are gone{.}:\ {King }Henry VI{,} Part I{ I-ii}:\ She is a woman{,} therefore may be woo'd{;}:\ She is a woman{,} therefore may be [won|screw'd]{.}:\ Titus Andronicus{ II-i}:\ Demetrius Such duty as the subject owes the prince{,}:\ Even such a woman oweth to her husband{.}:\ {The }Taming of the Shrew{ V-ii}:\ Kate Who is Silvia{?} what is she{,}:\ That all our swains commend her{?}:\ {The }Two Gentlemen of Verona{ IV-ii}:\ Thurio Tu-whit{,} tu-who[ - | |--]a merry note{,}:\ While greasy Joan doth keel the pot{.}:\ Love's Labo{u}r Lost{ V-ii}:\ Winter My only love sprung from my only hate{!}:\ Too early seen unknown{,} and known too late{!}:\ Romeo{ and Juliet{ I-v}}:\ Juliet But{,} soft{!} what light through yonder window breaks{?}:\ It is the east{,} and Juliet is the sun{!}:\ Romeo{ and Juliet{ II-ii}}:\ Romeo What's in a name{?} That which we call a rose:\ By any other name would smell as sweet{.}:\ Romeo{ and Juliet{ II-ii}}:\ Juliet Good night{,} good night{!} parting is such sweet sorrow{,}:\ That I shall say good night till it be morrow{.}:\ Romeo{ and Juliet{ II-ii}}:\ Juliet A plague o['|n] both your houses{!}:\ They have made worms' meat of me{.}:\ Romeo{ and Juliet{ III-i}}:\ Mercutio This royal throne of kings{,} this scepter['|e]d isle{,}:\ This earth of majesty{,} this seat of Mars{,}:\ {King }Richard II{ II-i}:\ John of Gaunt Not all the water in a rough rude sea:\ Can wash the balm from an anointed king{.}:\ {King }Richard II{ III-ii}:\ {King }Richard II I'll put a girdle round the earth:\ In forty minutes{.}:\ {A }Midsummer[-| ]Night's Dream{ II-i}:\ Puck I can call spirits from the vasty deep{.}:\ Why{,} so can I{,} or so can any man{;}:\ {King }Henry IV{,} Part I{ II-iv}:\ There are more things in heaven and earth{,} Horatio{,}:\ Than are dream[t|ed] of in your philosophy{.}:\ Hamlet{ I-v}:\ Hamlet The time is out of joint{;} O cursed spite{,}:\ That ever I was born to set it right{!}:\ Hamlet{ I-v}:\ Hamlet Once more unto the breach{,} dear friends{,} once more{;}:\ Or close the wall up with our English dead{.}:\ {King }Henry V{ III-i}:\ {King }Henry V Was ever woman in this humour woo['|e]d{?}:\ Was ever woman in this humour [won|screw'd]{?}:\ {King }Richard III{ I-ii}:\ {King }Richard III Now is the winter of our discontent:\ Made glorious summer by this sun of York:\ {King }Richard III{ I-i}:\ {King }Richard III There['s| is] a divinity that shapes our ends{,}:\ Rough[-| ]hew them how we will{.}:\ Hamlet{ V-ii}:\ Hamlet There is a tide in the affairs of men:\ Which{,} taken at the flood{,} leads on to fortune{;}:\ {Julius }Caesar{ IV-iii}:\ Brutus Never{,} never{,} never{,} never{,} never{.}:\ Pray you undo this button{.}{ Thank you{,} sir{.}}:\ {King }Lear{ V-iii}:\ {King }Lear I grow{,} I prosper{\:}:\ Now{,} gods{,} stand up for bastards{!}:\ {King }Lear{ I-ii}:\ Edmund The better part of valour is discretion{;}:\ in the which better part I have saved my life{.}:\ {King }Henry IV{,} Part I{ V-iv}:\ Falstaff Asses are made to bear{,} and so are you{.}:\ Women are made to bear{,} and so are you{.}:\ {The }Taming of the Shrew{ II-i}:\ Full fathom five thy father lies{;}:\ Of his bones are coral made{;}:\ {The }Tempest{ I-ii}:\ Ariel She lov['|e]d me for the dangers I had pass['|e]d{;}:\ And I lov['|e]d her that she did pity them{.}:\ Othello{ I-iii}:\ Othello Uneasy lies the head that wears a crown{.}:\ Many good morrows to your Majesty{!}:\ {King }Henry IV{,} Part II{ III-i}:\ Mislike me not for my complexion{,}:\ The shadow['|e]d livery of the burnish['|e]d sun{.}:\ {The }Merchant{ of Venice{ II-i}}:\ Morocco Cowards die many times before their deaths{;}:\ The valiant never taste of death but once{.}:\ {Julius }Caesar{ II-ii}:\ Caesar O{h}{!|,} Pardon me{,} thou bleeding piece of earth{,}:\ That I am meek and gentle with these butchers{.}:\ {Julius }Caesar{ III-i}:\ {Mark }Antony The play's the thing:\ Wherein I'll catch the conscience of the king{.}:\ Hamlet{ II-ii}:\ Hamlet How sharper than a serpent's tooth it is:\ to have a thankless child{.}:\ {King }Lear{ I-iv}:\ {King }Lear Had I but served my God with half the zeal I served my king:\ He would not in [mine|my] old age have left me naked to [mine|my] enemies{.}:\ {King }Henry VIII{ IV-ii}:\ {Cardinal }Wolsey It seems she hangs upon the cheek of night:\ Like a rich jewel in an Ethiop's ear{.}:\ Romeo{ and Juliet{ I-v}}:\ Romeo Where the bee sucks{,} there suck I{;}:\ In a cowslip's bell I lie{.}:\ {The }Tempest{ V-i}:\ Ariel O brave new world{,}:\ That has such people [in't|in it]{!}:\ {The }Tempest{ V-i}:\ Miranda Why{,} then the world's mine oyster{,}:\ Which I with sword will open{.}:\ {The }Merry Wives of Windsor{ II-ii}:\ Falstaff A goodly apple rotten at the heart{\:}:\ O{h}{,} what a goodly outside falsehood hath{!|.}:\ {The }Merchant{ of Venice{ I-iii}}:\ Antonio I never kill['|e]d a mouse{,} nor hurt a fly{;}:\ I trod upon a worm against my will{,}:\ Pericles{ IV-i}:\ Marina Golden lads and girls all must{,}:\ Like chimney sweepers{,} come to dust{.}:\ Cymbeline{ IV-ii}:\ Guiderius You blocks, you stones, you worse than senseless things!:\ O you hard hearts{,} you cruel men of Rome{.}:\ {Julius }Caesar{ I-i}:\ Marullus A horse{!|,} a horse{!|,} my kingdom for a horse{!}:\ :\ {King }Richard III{ V-iv}:\ {King }Richard III My salad days,:\ When I was green in judg{e}ment, cold in blood{,}:\ Antony [and|&] Cleopatra{ I-v}:\ Cleopatra Age cannot wither her, nor custom stale:\ Her infinite variety{.}:\ Antony [and|&] Cleopatra{ II-iii}:\ Enobarbus Give me some music\: music, moody food:\ Of us that trade in love{.}:\ Antony [and|&] Cleopatra{ II-v}:\ Cleopatra 'Tis better playing with a lion's whelp,:\ Than with an old one dying{.}:\ Antony [and|&] Cleopatra:\ Enobarbus The barge she sat in, like a burnished throne,:\ Burned on the water{.} The poop was burnished gold{;|.}:\ Antony [and|&] Cleopatra:\ Enobarbus Done like a Frenchman - turn and turn again!:\ :\ {King }Henry VI{,} Part I{ III-iii}:\ {Joan }Pucelle|{Saint |St{.} }Joan{ of Arc} bsd-games-2.17/quiz/datfiles/pres0000664000175000017500000001025507240362720015463 0ustar jsm28jsm28{G{eorge} }Washington:1789-{17}97:{J{ohn} }Adams:{J{ohn} }Adams {J{ohn} }Adams:1797-1801:{T{homas} }Jefferson:{T{homas} }Jefferson {T{homas} }Jefferson:1801-{{18}0}9:{A{aron} }Burr|{G{eorge} }Clinton:\ {J{ames} }Madison {J{ames} }Madison:1809-{18}17:{G{eorge} }Clinton|{E{lbridge} }Gerry:\ {J{ames} }Monroe {J{ames} }Monroe:1817-1825:\ {D{aniel} }{D{.} }Tompkins:{J{ohn} }{Q{uincy} }Adams {J{ohn} }{Q{uincy} }Adams:1825-{{18}2}9:{J{ohn} }{C{aldwell} }Calhoun:\ {A{ndrew} }Jackson {A{ndrew} }Jackson:1829-{18}37:\ {J{ohn} }{C{aldwell} }Calhoun|{M{artin} }Van Buren:{M{artin} }Van Buren {M{artin} }Van Buren:1837-{18}41:\ {R{ichard} }{M{entor} }Johnson:{W{illiam|m} }{H{enry} }Harrison {W{illiam|m} }{H{enry} }Harrison:1841:{J{ohn} }Tyler:{J{ohn} }Tyler {J{ohn} }Tyler:1841-{{18}4}5:[N|n]one{ (1841-5)}:{J{ames} }{K{nox} }Polk {J{ames} }{K{nox} }Polk:1845-{{18}4}9:\ {G{eorge} }{M{ifflin} }Dallas:{Z{achary} }Taylor {Z{achary} }Taylor:1849-{18}50:{M{illard} }Fillmore:{M{illard} }Fillmore {M{illard} }Fillmore:1850-{{18}5}3:[N|n]one{ (1850-3)}:{F{ranklin} }Pierce {F{ranklin} }Pierce:1853-{{18}5}7:\ {W{illiam|m} }{R{ufus} }{de Vane }King:{J{ames} }Buchanan {J{ames} }Buchanan:1857-{18}61:\ {J{ohn} }{C{abell} }Breckinridge:{A{braham|be} }Lincoln {A{braham|be} }Lincoln:1861-{{18}6}5:\ {H{annibal} }Hamlin|{A{ndrew} }Johnson:{A{ndrew} }Johnson {A{ndrew} }Johnson:1865-{{18}6}9:[N|n]one{ (1865-9)}:\ {U{lysses} }{S{impson} }Grant {U{lysses} }{S{impson} }Grant:1869-{18}77:\ {S{chuyler} }Colfax|{H{enry} }Wilson:{R{utherford} }{B{irchard} }Hayes {R{utherford} }{B{irchard} }Hayes:1877-{18}81:\ {W{illiam|m} }{A{lmon} }Wheeler:{J{ames} }{A{bram} }Garfield {J{ames} }{A{bram} }Garfield:1881:\ {C{hester} }{A{lan} }Arthur:{C{hester} }{A{lan} }Arthur {C{hester} }{A{lan} }Arthur:1881-{{18}8}5:[N|n]one{ (1881-5)}:\ {G{rover} }Cleveland{ (1st term)} {G{rover} }Cleveland{ (1st term)}:1885-{{18}8}9:\ {T{homas} }{A{ndrews} }Hendricks:{B{enjamin} }Harrison {B{enjamin} }Harrison:1889-{18}93:\ {L{evi} }{P{arsons} }Morton:{G{rover} }Cleveland{ (2nd term)} {G{rover} }Cleveland{ (2nd term)}:1893-{18}97:\ {A{dlai} }{E{wing} }Stevenson:{W{illiam|m} }McKinley {W{illiam|m} }McKinley:1897-1901:\ {G{arret} }{A{ugustus} }Hobart|{T{heodore|eddy} }Roosevelt|TR:\ {T{heodore|eddy} }Roosevelt|TR {T{heodore|eddy} }Roosevelt|TR:1901-{{19}0}9:\ {C{harles} }{W{arren} }Fairbanks:{W{illiam|m} }{H{oward} }Taft {W{illiam|m} }{H{oward} }Taft:1909-{19}13:\ {J{ames} }{S{choolcraft} }Sherman:{W{oodrow} }Wilson {W{oodrow} }Wilson:1913-{19}21:\ {T{homas} }{R{iley} }Marshall:{W{arren} }{G{amaliel} }Harding {W{arren} }{G{amaliel} }Harding:1921-{{19}2}3:{C{alvin} }Coolidge:\ {C{alvin} }Coolidge {C{alvin} }Coolidge:1923-{{19}2}9:\ {C{harles} }{G{ates} }Dawes:{H{erbert} }{C{lark} }Hoover {H{erbert} }{C{lark} }Hoover:1929-{19}33:\ {C{harles} }Curtis:{F{ranklin} }{D{elano} }Roosevelt|FDR {F{ranklin} }{D{elano} }Roosevelt|FDR:1933-{19}45:\ {J{ohn} }{N{ance} }Garner|{H{enry} }{A{gard} }Wallace|{H{arry} }{S }Truman:\ {H{arry} }{S }Truman {H{arry} }{S }Truman:1945-{19}53:\ {A{lben} }{W{illiam} }Barkley:{D{wight} }{D{avid} }Eisenhower {D{wight} }{D{avid} }Eisenhower:1953-{19}61:\ {R{ichard} }{M{ilhous} }Nixon:{J{ohn} }{F{itzgerald} }Kennedy|JFK {J{ohn} }{F{itzgerald} }Kennedy|JFK:1961-{{19}6}3:\ {L{yndon} }{B{aines} }Johnson|LBJ:{L{yndon} }{B{aines} }Johnson|LBJ {L{yndon} }{B{aines} }Johnson|LBJ:1963-{{19}6}9:\ {H{ubert} }{H{oratio} }Humphrey:{R{ichard} }{M{ilhous} }Nixon {R{ichard} }{M{ilhous} }Nixon:1969-{19}74:\ {S{piro} }{T{heodore} }Agnew|{G{erald} }{R{udolph} }Ford:\ {G{erald} }{R{udolph} }Ford {G{erald} }{R{udolph} }Ford:1974-{{19}7}7:\ {N{elson} }{A{ldrich} }Rockefeller:{J{ames} }{E{arl} }Carter{{,} J{unio}r} {J{ames} }{E{arl} }Carter{{,} J{unio}r}:1977-{19}81:\ {W{alter} }{F{rederick} }Mondale:{R{onald} }{W{ilson} }Reagan {R{onald} }{W{ilson} }Reagan:1981-{{19}8}9:\ {G{eorge} }{H{erbert} }{W{alker} }Bush:{G{eorge} }{H{erbert} }{W{alker} }Bush {G{eorge} }{H{erbert} }{W{alker} }Bush:1989-{19}93:\ {J{ames} }{D{anforth|an} }Quayle:{W{illiam|m} }{J{efferson} }Clinton {W{illiam|m} }{J{efferson} }Clinton:1993-2001:\ {A{lbert} }{A{rnold} }Gore{{,} J{unio}r}:{G{eorge} }{W{alker} }Bush{{,} J{unio}r} {G{eorge} }{W{alker} }Bush{{,} J{unio}r}:2001-:\ {R{ichard} }{B{ruce} }Cheney: bsd-games-2.17/quiz/datfiles/inca0000664000175000017500000000045506363445554015441 0ustar jsm28jsm28manco capac:sinchi roca sinchi roca:lloque yupanqui lloque yupanqui:mayta capac mayta capac:capac yupanqui capac yupanqui:inca roca inca roca:yahuar huacac yahuar huacac:viracocha viracocha:pachacuti pachacuti:tupa inca yupanqui tupa inca yupanqui:huayna capac huayna capac:huascar huascar:atahuallpa bsd-games-2.17/quiz/datfiles/ucc0000664000175000017500000001505506363445554015303 0ustar jsm28jsm281-103:supplementary general principles of law applicable 1-106:remedies to be liberally administered 1-201:general definitions 1-203:obligation of good faith 1-205:course of dealing and usage of trade 1-206:statue of frauds for kinds of personal property not otherwise covered 2-103:definitions-sales 2-201:statute of frauds 2-208:course of performance or practical consideration 2-302:unconscionable contract or clause 2-310:open time for payment or running of credit 2-319:FOB and FAS terms 2-320:CIF and C&F terms 2-323:form of bill of lading required in overseas shipment 2-401:passing of title; reservation for security 2-402:rights of seller's creditors against sold goods 2-403:powr to transfer; good faith purchase of goods; entrusting 2-501:insurable interest in goods; manner of identification of goods 2-502:buyer's right to goods on seller's insolvency 2-503:manner of seller's tender of delivery 2-506:rights of financing agency 2-507:effect of seller's tender; delivery on condition 2-508:cure by seller of improper tender or delivery; replacement 2-509:risk of loss in the absence ogf breach 2-510:effect of breach on risk of loss 2-513:buyer's right to inspection of goods 2-601:buyer's rights on improper delivery 2-602:manner and effect of rightful rejection 2-603:merchant buyer's duties as to rightfully rejected goods 2-605:waiver of buyer's objections by failure to particularize 2-606:what constitutes acceptance of goods 2-607:effect of acceptance; notice of breach 2-608:revocation of acceptance in whole or in part 2-609:right to adequate assurance of performance 2-610:anticipatory repudiation 2-611:retraction of anticipatory repudiation 2-612:installment contract; breach 2-702:seller's remedies on discovery o buyer's insolvency 2-703:seller's remedies in general 2-705:seller's stoppage of delivery in transit or otherwise 2-706:seller's resale including contract for resale 2-708:seller's damages for non-acceptance or repudiation 2-709:action for the price 2-711:buyer's remedies in general; buyer's security interest in rejected goods 2-712:cover; buyer's procurement of substitute goods 2-713:buyer's damages for on-delivery or repudiation 2-714:buyer's damages for breach in regard to accepted goods 2-715:buyer's incidental and consequential damages 2-716:buyer's right to specific performance or replevin 3-102:definitions-commercial paper 3-104:form of negotiable instruments; draft; check; certificate of deposit; note 3-110:payable to order 3-111:payable to bearer 3-201:transfer: right to indorsement 3-202:negotiation 3-204:special indorsement; blank indorsement 3-301:rights of a holder 3-302:holder in due course 3-305:rights of a holder in due course 3-306:rights of one not holder in due course 3-401:signature 3-404:unauthorized signature 3-405:impostors; signature in name of payee 3-406:negligence contributing to alteration or unauthorized signature 3-407:alteration 3-410:definition and operation of acceptance 3-411:certification of a check 3-413:contract of maker, drawer and acceptor 3-414:contract of indorser; order of liability 3-417:warranties on presentment and transfer 3-418:finality of payment or acceptance 3-419:conversion of instrument; innocent representative 3-501:when presentment, notice of dishonor, and protest necessary or permissible 3-502:unexcused delay; discharge 3-503:time or presentment 3-507:dishonor; holder's right of recourse; term allowing representment 3-508:notice of dishonor 3-511:waived or excused presentment, protest or notice of dishonor or delay therein 3-601:discharge of parties 3-802:effect of instrument on obligation for which it is given 3-804:lost,destroyed or stolen instruments 4-104:definitions-bank deposits and collections 4-105:banks-depositary, intermediary, collecting, payor, presenting, remitting 4-207:warranties of customer and collecting bank on transfer or presentment of items 4-208:security interest of collecting bank in items, accompanying documents and proceeds 4-209:when bank gives value for purposes of holder in due course 4-211:media of remittance; provision and final settlement in remittance cases 4-213:final payment of item by payor bank 4-401:when bank may charge customer's account 4-406:customer's duty to discover and report unauthorized signature or alteration 4-402:bank liability to customer for wrongful dishonor 4-407:payor bank's right to subrogation on improper payment 5-111:warranties on transfer and presentment (letters of credit) 5-114:issuer's duty and privilege to honor; right to reimbursement 5-115:remedy for improper dishonor or anticipatory repudiaion (letters of credit) 7-104:negotiable and non-negotiable warehouse receipt, bill of lading, other title 7-204:duty of care; contractual limitation of warehouseperson's liability 7-301:liability for non-receipt or misdescription 7-403:obligation of warehouseperson or carrier to deliver; excuse 7-404:no liability for good faith delivery pursuant to receipt or bill 7-501:form of negotiation and requirements of due negotiation 7-502:rights acquired by due negotiation 7-503:document of title to goods defeated in certain cases 7-504:rights acquired in absence of due negotiation; effect of diversion 7-507:warranties on negotiation or transfer of receipt or bill 7-508:warranties of collecting bank as to documents 9-105:definitions-secured transactions 9-107:definitions "purchase money security interest" 9-109:classification of goods; consumer goods; equipment; farm products; inventory 9-113:security interests arising under article on sales 9-203:attachment and enforceability of security interest; proceeds; formal requisites 9-206:agreement not to asserr defenses against assignee; modification of sales warranties 9-301:persons who take priority over unperfected security interests 9-302:when filing is required to perfect security interest 9-303:when security interest is perfected 9-304:perfection of security interest in instruments, documents 9-305:when possession by secured party perfects security interest without filing 9-306:proceeds; secured party's rights on disposition of collateral 9-307:protection of buyers of goods 9-310:periority of certain liens arising by opration of law (mechanic's liens) 9-311:alienability of debtor's rights; judicial process 9-312:priorities among conflicting security interests in the same collateral 9-405:assignment of security interest 9-501:default; procedure when security agreement covers real and personal property 9-503:secured party's right to take possession after default 9-504:secured party's right to dispose of collateral after default 9-505:compulsory disposition of collateral; acceptance of collateral as discharge of obligation bsd-games-2.17/quiz/datfiles/spell0000664000175000017500000000011206363445554015634 0ustar jsm28jsm28The son went behind a cloud.:sun Did you see the monky at the zoo?:monkey bsd-games-2.17/quiz/datfiles/asia0000664000175000017500000000134007077410364015430 0ustar jsm28jsm28Afghanistan:Kabul Australia:Canberra Bahrein:Manama Bangladesh:Dacca Bhutan:Thimbu Burma:Rangoon Cambodia|Khmer:P{h}nom Penh China:Peking Cyprus:Nicosia India:New Delhi Indonesia:Jakarta|Djakarta Iran:Tehran Iraq:Baghdad Israel:Jerusalem Japan:Tokyo Jordan:Amman Kuwait:Al-kuwait Laos:Vientiane Lebanon:Beirut Malaysia:Kuala Lumpur Maldive Islands:Male Mongolia:Ulan Bator Nepal:Katmandu North Korea:P{'}yongyang North Yemen:San{'}a Oman:Muscat Pakistan:Islamabad Papua[-| ]New Guinea:Port Moresby Philippines:Manila Qatar:Doha Saudi Arabia:Riyadh|J{ei}ddah Singapore:Singapore South Korea:Seoul South Yemen:Aden Sri Lanka:Colombo Syria:Damascus Taiwan:Taipei Thailand:Bangkok Turkey:Ankara United Arab Emirates:Abu Dhabi Vietnam:Hanoi bsd-games-2.17/quiz/datfiles/murders0000664000175000017500000000164206363445554016207 0ustar jsm28jsm28Cock Robin:{the }sparrow sleep|Duncan:Macbeth {the }cat:curiosity|care {John {F{.} }}Kennedy|JFK:{Lee Harvey }Oswald|{the }FBI|{the }CIA {Lee Harvey }Oswald:{Jack }Ruby|{the }FBI|{the }CIA {Martin Luther }King:{James {Earl }}Ray|{the }FBI|{the }CIA [Bobby |Robert {F{.} }]Kennedy|RFK:{Sirhan }Sirhan|{the }FBI|{the }CIA Christ:{the }Romans|{Pontius }Pilate|{the }CIA {Sharon }Tate:{Charles }Manson Charles Lindbergh Jr{.}:{Bruno }Hauptman{n} {Mr{.} }{{and }Mrs{.} }Borden|{her }parents:Lizzie{ Borden} {Prof{essor} }{James }Moriarty:{Sherlock }Holmes Achilles:Paris Abel:Cain {the }nurses:{Richard }Speck {J{.} |Julius }Caesar:Brutus{ et al.} Pompeii:Vesuvius {Abraham |Abe }Lincoln:{John {Wilkes }}Booth {Yukio }Mishima:{Yukio }Mishima {Alexander }Hamilton:{Aaron }Burr Cleopatra:{the |an }asp [Ann Boleyn|Catharine Howard]:Henry{ VIII} vaudeville:{the }movies|film {the }movies|film:TV|television {the }VA patients:{the }nurses bsd-games-2.17/quiz/datfiles/state0000664000175000017500000000367706363445554015660 0ustar jsm28jsm28Alabama|Ala|AL:Montgomery:AL:goldenrod Alaska|AK:Juneau:AK:forget{-| }me{-| }not Arizona|Ariz|AZ:Phoenix:AZ:{saguaro }cactus Arkansas|Ark|AR:Little Rock:AR:gok Cal{if{ornia}}|CA:Sacramento:CA:{golden }poppy Col{o{rado}}|CO:Denver:CO:columbine Conn{ecticut}|CT:Hartford:CT:{mountain }laurel Del{aware}|DE:Dover:DE:peach{ blossom} Fl{orid}a|FL:Tallahassee:FL:orange{ blossom} Georgia|Ga:Atlanta:GA:{Cherokee }rose Hawaii|HI:Honolulu:HI:hibiscus Idaho|Ida|ID:Boise:ID:syringa Ill{inois}|IL:Springfield:IL:violet Ind{iana}|IN:Indianapolis:IN:zinnia Iowa|Ia:Des Moines:IA:{wild }rose Kans{as}|Kan|KS:Topeka:KS:sun{ }flower Kentucky|Ky:Frankfort:KY:goldenrod Louisiana|La:Baton Rouge:LA:magnolia Maine|Me:Augusta:ME:pinecone{ and}{ tassel} Maryland|Md:Annapolis:MD:blackeyed susan Mass{achusetts}|MA:Boston:MA:{trailing }arbutus Mich{igan}|MI:Lansing:MI:apple{ blossom} Minn{esota}|MN:Saint Paul|St Paul:MN:gok Miss{issippi}|MS:Jackson:MS:magnolia Missouri|Mo:Jefferson City:MO:hawthorn Mont{ana}|MT:Helena:MT:bitterroot Nebraska|Neb|NE|NB:Lincoln:NE|NB:goldenrod Nevada|Nev|NV:Carson City:NV:sagebrush New Hampshire|NH:Concord:NH:{purple }lilac New Jersey|NJ:Trenton:NJ:violet New Mexico|NM:Santa Fe:NM:yucca New York|NY:Albany:NY:{wild }rose N{orth} Carolina|NC:Raleigh:NC:dogwood N{orth} Dakota|ND:Bismarck:ND:{wild }{prarie }rose Ohio|O|OH:Columbus:OH:{scarlet }carnation Oklahoma|Okla|OK:Oklahoma City:OK:mistletoe Oregon|Ore|OR:Salem:OR:{Oregon }grape Pennsylvania|Pa:Harrisburg:PA:{mountain }laurel Rhode Island|RI:Providence:RI:violet S{outh} Carolina|SC:Columbia:SC:{yellow }jasmine S{outh} Dakota|SD:Pierre:SD:pasque{ flower} Tenn{essee}|TN:Nashville:TN:iris Texas|Tex|TX:Austin:TX:blue{-| }bonnet Utah|UT:Salt Lake City:UT:{sego }lilly Vermont|Vt:Montpelier:VT:{red }clover Virginia|Va:Richmond:VA:dogwood Wash{ington}|WA:Olympia:WA:rhododendron W{est} Virginia|W{ }Va|WV:Charleston:WV:rhododendron Wisconsin|Wis|WI:Madison:WI:violet Wyo{ming}|WY:Cheyenne:WY:indian paint brush bsd-games-2.17/quiz/datfiles/flowers0000664000175000017500000000240407343203043016164 0ustar jsm28jsm28African violet:Such worth is rare Apple blossom:Preference Bachelor's button:Celibacy Bay leaf:I change but in death Camellia:Reflected loveliness Chrysanthemum, non-red/white:Slighted love Chrysanthemum, red:I love Chrysanthemum, white:Truth Clover:Be mine Crocus:Abuse not Daffodil:Innocence Dead leaves:Melancholy Forget-me-not:True love Fuchsia:Fast Gardenia:Secret, untold love Honeysuckle:Bonds of love Ivy:Friendship, fidelity, marriage Jasmine:Amiability, transports of joy, sensuality Lilac:Youthful innocence Lilly of the valley:Return of happiness Lilly:Purity, sweetness Magnolia:Dignity, perseverance Marigold:Jealousy Mint:Virtue Orange blossom:Your purity equals your loveliness Orchid:Beauty, magnificence Pansy:Thoughts Peach blossom:I am your captive Petunia:Your presence soothes me Poppy:Sleep Rose, any color:Love Rose, deep red:Bashful shame Rose, single, pink:Simplicity Rose, thornless, any color:Early attachment Rose, white:I am worthy of you Rose, yellow:Decrease of love, rise of jealousy Rosebud, white:Girlhood, and a heart ignorant of love Rosemary:Remembrance Sunflower:Haughtiness Tulip, red:Declaration of love Tulip, yellow:Hopeless love Upside down:Reverses meaning Violet, blue:Faithfulness Violet, white:Modesty Zinnia:Thoughts of absent friends bsd-games-2.17/quiz/datfiles/mult0000664000175000017500000000154406363445554015510 0ustar jsm28jsm281 x 0:0 1 x 1:1 1 x 2:2 1 x 3:3 1 x 4:4 1 x 5:5 1 x 6:6 1 x 7:7 1 x 8:8 1 x 9:9 1 x 10:10 2 x 0:0 2 x 1:2 2 x 2:4 2 x 3:6 2 x 4:8 2 x 5:10 2 x 6:12 2 x 7:14 2 x 8:16 2 x 9:18 2 x 10:20 3 x 0:0 3 x 1:3 3 x 2:6 3 x 3:9 3 x 4:12 3 x 5:15 3 x 6:18 3 x 7:21 3 x 8:24 3 x 9:27 3 x 10:30 4 x 0:0 4 x 1:4 4 x 2:8 4 x 3:12 4 x 4:16 4 x 5:20 4 x 6:24 4 x 7:28 4 x 8:32 4 x 9:36 4 x 10:40 5 x 0:0 5 x 1:5 5 x 2:10 5 x 3:15 5 x 4:20 5 x 5:25 5 x 6:30 5 x 7:35 5 x 8:40 5 x 9:45 5 x 10:50 6 x 0:0 6 x 1:6 6 x 2:12 6 x 3:18 6 x 4:24 6 x 5:30 6 x 6:36 6 x 7:42 6 x 8:48 6 x 9:54 6 x 10:60 7 x 0:0 7 x 1:7 7 x 2:14 7 x 3:21 7 x 4:28 7 x 5:35 7 x 6:42 7 x 7:49 7 x 8:56 7 x 9:63 7 x 10:70 8 x 0:0 8 x 1:8 8 x 2:16 8 x 3:24 8 x 4:32 8 x 5:40 8 x 6:48 8 x 7:56 8 x 8:64 8 x 9:72 8 x 10:80 9 x 0:0 9 x 1:9 9 x 2:18 9 x 3:27 9 x 4:36 9 x 5:45 9 x 6:54 9 x 7:63 9 x 8:72 9 x 9:81 9 x 10:90 bsd-games-2.17/quiz/datfiles/seq-easy0000664000175000017500000000132206363445554016250 0ustar jsm28jsm281,2,3,4,5,6:7{(integers)}:integers|[natural|counting] numbers 1,2,3,5,8,13:21{(Fibonacci)}:Fibonacci{ seq{ence}| numbers} 1,2,4,8,16,32:64{(powers of 2)}:powers of 2|2[**|^]n 1,2,6,24,120,720:5040{(factorials)}:factorials|n! 1,3,5,7,9,11:13{(odd nos.)}:odd [integ|numb]ers 1,3,6,10,15,21:28{(triangular)}:triangular{ numbers}|C(n,2) 1,3,9,27,81:243{(powers of 3)}:powers of 3|3[**|^]n 1,4,9,16,25:36{(squares)}:squares|n[**|^]2 1,4,16,64:256{(powers of 4)}:powers of 4|4[**|^]n 1,5,25,125:625{(powers of 5)}:powers of 5|5[**|^]n 1,8,27,64,125:216{(cubes)}:cubes|n[**|^]3 2,3,5,7,11,13:17{(primes)}:prime[ number]s 2,4,6,8,10,12:14{(even nos.)}:even [integ|numb]ers|multiples of 2|2n 3,6,9,12,15:18{(3n)}:multiples of 3|3n bsd-games-2.17/quiz/datfiles/morse0000664000175000017500000000024006363445554015644 0ustar jsm28jsm28A:.- B:-... C:-.-. D:-.. E:. F:..-. G:--. H:.... I:.. J:.--- K:-.- L:.-.. M:-- N:-. O:--- P:.--. Q:--.- R:.-. S:... T:- U:..- V:...- W:.-- X:-..- Y:-.-- Z:--.. bsd-games-2.17/quiz/datfiles/africa0000664000175000017500000000157506363445554015760 0ustar jsm28jsm28Algeria:Alg[iers|er] Botswana:Gaberones Burundi:Bujumbura Cameroun:Yaound['e|e'|e] Central Africa{n Rep{ublic}}:Bangui Chad:Ndjamena Congo:Brazzaville Dahomey:Porto Novo Ethiopia:Addis Ababa Gabon:Libreville Ghana:Accra Guinea-Bissau:Bissau Guinea:Conakry Ivory Coast:Abidjan Kenya:Nairobi Lesotho:Maseru Liberia:Monrovia Libya:Al Bayda{'} Malagasy{ Rep{ublic}}|Madagascar:Tananarive Malawi:Zomba Mali:Bamako Mauritania:Nouakchott Morocco:Rabat Mo[z|,c|c,|c]ambique:Louren[,c|c,|c]o Marques Niger:Niamey Nigeria:Lagos Rhodesia:Salisbury Rwanda:Kigali Senegal:Dakar Sierra Leone:Freetown Somali{ Rep{ublic}}:Mogadis[cio|hu] Sudan:Khartoum Swaziland:Mbabane Tanzania:Dar es Salaam Togo:Lom['e|e'|e] Tunisia:Tunis Uganda:Kampala United Arab Rep{ublic}|Egypt:Cairo Upper Volta:Ouagadougou Zambia:Lusaka Za["i|i"|i]re:Kinshasha {Rep{ublic} of }South Africa:Pretoria {The }Gambia:Bathurst bsd-games-2.17/quiz/datfiles/sexes0000664000175000017500000000062506363445554015655 0ustar jsm28jsm28Y|y:X|x abbot:abbess alumnus:alumna ambassador:ambassadress boar:sow buck:doe bull:cow cob:pen colt:filly curator:curatrix dog:bitch|vixen duke:duchess drake:duck effeminate|womanish:mannish gander:goose gentleman:lady|gentlewoman jack:jenny lad:lass manly:womanly marquis:marchioness[|e]|marquise monk:nun [O|o]edipus complex:[E|e]lectra[| complex] prince:princess ram:ewe rooster|cock:hen stallion:mare bsd-games-2.17/quiz/datfiles/areas0000664000175000017500000000747206363445554015630 0ustar jsm28jsm28201:northern new jersey|NJ:newark 202:washington d c|DC: 203:connecticut|CT: 204:manitoba: 205:alabama|AL: 206:western washington state|WA:seattle 207:maine|ME: 208:idaho|ID: 209:central california|CA:fresno 212:new york city, new york|NY: 213:los angeles, california|CA: 214:northeastern texas|TX:dallas 215:southeastern pennsylvania|PA:philadelphia 216:northeastern ohio|OH:akron 217:central illinois|IL:springfield 218:northern minnesota|MN:duluth 219:northern indiana|IN:south bend 301:maryland|MD: 302:delaware|DE: 303:colorado|CO: 304:west virginia|WV: 305:southeastern florida|FL:miami 306:saskatchewan: 307:wyoming|WY: 308:western nebraska|NE:omaha 309:northwestern illinois|IL:peoria 312:chicago, illinois|IL: 313:eastern michigan|MI:detroit 314:southeastern missouri|MO:jefferson city 315:northern central new york|NY:syracuse 316:southern kansas|KS:wichita 317:central indiana|IN:indianapolis 318:western louisiana|LA:shreveport 319:eastern iowa|IA:cedar rapids 401:rhode island|RI: 402:eastern nebraska|NE:north platte 403:alberta: 404:northern georgia|GA:atlanta 405:western oklahoma|OK:oklahoma city 406:montana|MT: 408:central coastal california|CA:san jose 412:western pennsylvania|PA:pittsburgh 413:western massachusetts|MA:springfield 414:southeastern wisconsin|WI:milwaukee 415:san francisco, california|CA: 416:southern central ontario:toronto 417:southwestern missouri|MO:springfield 418:northeastern quebec:quebec 419:northwestern ohio|OH:toledo 501:arkansas|AR: 502:western kentucky|KY:louisville 503:oregon|OR: 504:eastern louisiana|LA:new orleans 505:new mexico|NM: 506:new brunswick: 507:southern minnesota|MN:rochester 509:eastern washington state|WA:spokane 512:southern texas|TX:austin 513:southwestern ohio|OH:dayton 514:southwestern quebec:montreal 515:central iowa|IA:des moines 516:long island, new york|NY: 517:central michigan|MI:lansing 518:northeastern new york|NY:albany 519:southwestern ontario:windsor 601:mississippi|MS: 602:arizona|AZ: 603:new hampshire|NH: 604:british columbia: 605:south dakota|SD: 606:eastern kentucky|KY:ashland 607:southern central new york|NY:ithaca, binghamton 608:southwestern wisconsin|WI:madison 609:southern new jersey|NJ:trenton 612:central minnesota|MN:minneapolis 613:southeastern ontario:ottawa 614:southeastern ohio|OH:columbus 615:eastern tennessee|TN:nashville 616:western michigan|MI:grand rapids 617:eastern massachusetts|MA:boston 618:southern illinois|IL:centralia 701:north dakota|ND: 702:nevada|NV: 703:western virginia|VA:arlington 704:western north carolina:charlotte 705:northeastern ontario:sault ste. marie 707:northwestern california|CA:santa rosa 709:newfoundland: 712:western iowa|IA:council bluffs 713:southeastern texas|TX:houston 714:southern california|CA:san diego 715:northern wisconsin|WI:superior 716:northern western new york|NY:buffalo, rochester 717:eastern pennsylvania|PA:wilkes-barre, scranton 801:utah|UT: 802:vermont|VT: 803:south carolina|SC: 804:eastern virginia|VA:richmond 805:southern central coastal california|CA:bakersfield 806:panhandle texas|TX:amarillo 807:western ontario:fort william 808:hawaii|HI: 809:bermuda, puerto rico, virgin islands, caribbean: 812:southern indiana|IN:evansville 813:southwestern florida|FL:st. petersburg 814:central pennsylvania|PA:erie 815:northeastern illinois|IL:rockford 816:northern missouri|MO:kansas city 817:northern central texas|TX:fort worth 819:northwestern quebec:trois rivieres 901:western tennessee|TN:memphis 902:nova scotia, prince edward island: 903:western mexico:mexicali 904:northern florida|FL:jacksonville 905:eastern mexico:mexico city 906:upper michigan|MI:escanaba 907:alaska|AK: 912:southern georgia|GA:savannah 913:northern kansas|KS:topeka 914:southern new york|NY:westchester county 915:western texas|TX:el paso 916:northeastern california|CA:sacramento 918:eastern oklahoma|OK:tulsa 919:eastern north carolina|NC:raleigh bsd-games-2.17/quiz/datfiles/ed0000664000175000017500000000705606363445554015123 0ustar jsm28jsm28prepare to add text at beginning of file:0a|1i find name of file being edited:f print last 3 lines of file:$-[2|-],$p print previous line:[-|^]{p}|{.}-{1}{p} print whole file:1,$p|g/[^|$]/p delete this line and next:.{,|;}[{.}+{1}|.1]d prepare to replace text from here to just before next "PP":\ .{,|;}/[PP|{^}\\.PP]/-{1}c find next "1.2":/1\\.2/{p} find next 2-or-more digit number:\ /\[[0|1]-9\]\[0-9\]/{p} move rest of this paragraph (separated by "PP") to end of previous one:\ [.,|{.}+{1},|.1,]/[PP|{^}\\.PP]/-{1}m[??|?{^}{\\.}PP?]-{1} print every "Oxygen" or "oxygen":[g|1,$g]/\[[Oo|oO]\]xygen/[p|.p] change each "BTL" in file to "Bell Laboratories" and check:\ [g|1,$g]/BTL/[s|.s]/[/|BTL/]Bell Laboratories/gp combine every even-numbered line with the next odd-numbered line:\ 2,${-{1}}g/[^|$]/[j|.,{.}+{1}j|.,.1j] print next "SH" and following line:\ /SH/;[{.}+{1}|.1]p|/SH/,[//|/SH/][{.}+{1}|.1]p print from next "TS" to following "TE":/TS/;/TE/p reverse order of lines in whole file:[g|1,$g]/^/[m|.m]0 replace each string of x's in current line by one x:\ [s|.s]/[x|\[x\]][x|\[x\]]*/x/g{p}{ (not s/x*/x/g)} change first "hte" in current line to "the" and check:[s|.s]/hte/the/p combine previous line and this one:\ [-,|^,|{.}-{1},].j go to line after third "PP" ahead:\ /[PP|{^}\\.PP]/;[//|/[PP|{^}\\.PP]/];[//|/[PP|{^}\\.PP]/]\ [{+}1|+]|;[{.}+{1}|.1]{ (not ...p)} exchange current line with previous line:\ [[-|^]m|{.}-{1}m].|{.}m[[--|^^]|{.}-2] move everything from here through "stop." to end of file:\ .,/stop\\./m$ current line has 2 fields separated by 1 blank; exchange them:\ [s|.s]/[\\|^\\]([.|\[^ \]]*\\) \\([.|\[^ \]]*\\)[/|$/]\\2 \\1/{p} insert a "0" after last "0" on current line:\ [s|.s]/[.*0/&0|^.*0/&0|0\\(\[^0\]*\\)$/[0&|00\1]|0\[^0\]*$/0&\ |\[^0\]*$/0&]/{p} replace "a*b" by "a**b":s/[a\\*b|a[*]b]/a**b/{p}|\ s/\\*/**/p attach the word "extra" to the end of the current line:\ [s|.s]/$/{ }extra/{p} replace "ATT" in current line by "AT&T":\ [s|.s]/ATT/AT\\&T/{g}{p} double the length of the current line by repetition:\ [s|.s]/[.*|.|^.*$]/&&/{p} look for another line containing what you just looked for:// find the previous line that contains a capital letter:?\[A-Z\]?{p} delete the next line that contains only capital letters:\ /^\[A-Z\]*$/d|/^\[A-Z\]\[A-Z\]*$/d place a copy of current line at the end of the file:\ t$|.{,.}t$ find how many lines there are:=|$= find the number of the current line:.= delete the first 3 lines of the file:1,3d delete every line that doesn't begin with "A":\ [v|1,$v]/^A/d{ (not g/^\[^A\]/d)} delete every empty line from here through next "LP":\ .,/[LP|{{^}\\.}LP]/g/^$/d print the line after each "AU":\ [g|1,$g]/[AU|{^}\\.AU]/[{.}+{1}|.1]{p} delete everything after "proud" from current line:\ [s|.s]/proud.*/proud/{p} delete part of current line from "alpha" through "omega":\ [s|.s]/alpha.*omega//{p} save everything up through current line in file "prefix":1,.w prefix prepare to add text at end of file:$a append the contents of file "suffix" to this file:$r suffix go back 10 lines:{.}-10{p}|---------- change every "01" in current line to "1":[s|.s]/01/1/g{p} go to next line that contains a double capital letter:\ /\\(\[A-Z\]\\)\\1/{p} place parens () around current line:\ [s|.s]/[.*|^.*$]/(&)/{p} the current line is too long for your terminal; print it to fit:\ l|.l put the work you've done back in the original file:w append the whole file to the file "unfinished":\ [W|1,$W] unfinished insert "\\&" at beginning of current line:\ [s|.s]/^/\\\\\\&/{p} list your current directory:!ls stop work on current file and shift to file "other":e other bsd-games-2.17/quiz/datfiles/elements0000664000175000017500000000412206363445554016336 0ustar jsm28jsm28H:1:1.008:Hydrogen He:2:4.003:Helium Li:3:6.94:Lithium Be:4:9.013:Beryllium B:5:10.82:Boron C:6:12.011:Carbon N:7:14.008:Nitrogen O:8:16.0:Oxygen F:9:19.0:Fluorine Ne:10:20.183:Neon Na:11:22.991:Sodium Mg:12:24.32:Magnesium Al:13:26.98:Aluminum Si:14:28.09:Silicon P:15:30.975:Phosphorus S:16:32.066:Sulphur Cl:17:35.457:Chlorine Ar:18:39.944:Argon K:19:39.1:Potassium Ca:20:40.08:Calcium Sc:21:44.96:Scandium Ti:22:47.9:Titanium V:23:50.95:Vanadium Cr:24:52.01:Chromium Mn:25:54.94:Manganese Fe:26:55.85:Iron Co:27:58.94:Cobalt Ni:28:58.71:Nickel Cu:29:63.54:Copper Zn:30:65.38:Zinc Ga:31:69.72:Gallium Ge:32:72.6:Germanium As:33:74.91:Arsenic Se:34:78.96:Selenium Br:35:79.916:Bromine Kr:36:83.8:Krypton Rb:37:85.48:Rubidium Sr:38:87.63:Strontium Y:39:88.92:Yttrium Zr:40:91.22:Zirconium Nb:41:92.91:Niobium Mo:42:95.95:Molybdenum Tc:43:(99):Technetium Ru:44:101.1:Ruthenium Rh:45:102.91:Rhodium Pd:46:106.4:Palladium Ag:47:107.88:Silver Cd:48:112.41:Cadmium In:49:114.82:Indium Sn:50:118.7:Tin Sb:51:121.76:Antimony Te:52:127.61:Tellurium I:53:126.91:Iodine Xe:54:131.3:Xenon Cs:55:132.91:Cesium Ba:56:137.36:Barium La:57:138.92:Lanthanum Ce:58:140.13:Cerium Pr:59:140.92:Praseodymium Nd:60:144.27:Neodymium Pm:61:(145):Promethium Sm:62:150.35:Samarium Eu:63:152.0:Europium Gd:64:157.26:Gadolinium Tb:65:158.93:Terbium Dy:66:162.51:Dysprosium Ho:67:164.94:Holmium Er:68:167.27:Erbium Tm:69:168.94:Thulium Yb:70:173.04:Ytterbium Lu:71:174.99:Lutetium Hf:72:178.5:Hafnium Ta:73:180.95:Tantalum W:74:183.86:Tungsten Re:75:186.22:Rhenium Os:76:190.2:Osmium Ir:77:192.2:Iridium Pt:78:195.09:Platinum Au:79:197.0:Gold Hg:80:200.61:Mercury Tl:81:204.39:Thallium Pb:82:207.21:Lead Bi:83:209.0:Bismuth Po:84:(210):Polonium At:85:(210):Astatine Rn:86:(222):Radon Fr:87:(223):Francium Ra:88:(226):Radium Ac:89:(227):Actinium Th:90:232.05:Thorium Pa:91:(231):Protactinium U:92:238.07:Uranium Np:93:(237):Neptunium Pu:94:(242):Plutonium Am:95:(243):Americium Cm:96:(248):Curium Bk:97:(247):Berkelium Cf:98:(249):Californium Es:99:(254):Einsteinium Fm:100:(253):Fermium Md:101:(256):Mendelevium No:102:(253):Nobelium Lw:103:(259):Lawrencium bsd-games-2.17/quiz/datfiles/greek0000664000175000017500000000037106363445554015621 0ustar jsm28jsm28$luw$:{I} [loose|destroy] $eluon$:{I} [loosed|destroyed|was loosing|was destroying] $elusa$:{I} [loosed|destroyed] $leluka$:{I} have [loosed|destroyed] $lusw$:{I} will [loose|destroy] $luswn$:[loosing|destroying] $lusas$:{having} [loosed|destroyed] bsd-games-2.17/quiz/datfiles/europe0000664000175000017500000000173007641273254016017 0ustar jsm28jsm28Albania:Tirana|Tirane" Andorra:Andorra la V[ell|iej]a Austria:Vienna|Wien Belarus|Byelorussia:M[i|e]nsk Belgium:Brussel[s|]|Bruxelles Bosnia[-Herzegovina|]:Sarajevo Bulgaria:Sofi[a|ya] Croatia:Zagreb Czech Republic:Prague|Praha Denmark:Copenhagen|K[o|o/]benhavn United Kingdom|England|Great Britain|UK:London Estonia:Tallinn Finland:Helsinki France:Paris Georgia:Tbilisi Germany:Berlin Greece:Athens Hungary:Budapest Iceland:Reykjavik Ireland|Eire:Dublin Italy:Rom[e|a] Latvia:Riga Liechtenstein:Vaduz Lithuania:Vilnius Luxembourg:Luxembourg [|Former Yugoslav Republic Of ]Macedonia:Skop[|l]je Malta:Valletta Moldova:Chisinau|Kishinev Monaco:Monaco Netherlands|Holland:Amsterdam Norway:Oslo Poland:Wars[aw|zawa] Portugal:Lisbo[n|a] R[u|o]mania:Bucharest|Bucuresti Russia:Mos[cow|kva] San Marino:San Marino Serbia and Montenegro:Belgrade|Beograd Slovakia|Slovak Republic:Bratislava Slovenia:Ljubljana Spain:Madrid Sweden:Stockholm Switzerland:Bern{e} Turkey:Ankara Ukraine:Kiev|Kyiv bsd-games-2.17/quiz/datfiles/sov0000664000175000017500000000316406363445554015336 0ustar jsm28jsm28W[illia|]m [I|1|the Conqueror]:11:W[illia|]m [II|2|Rufus|the Red] W[illia|]m [II|2|Rufus|the Red]:11:Hen[ry|] [I|1] Hen[ry|] [I|1]:12:Stephen Stephen:12:Hen[ry|] [II|2] Hen[ry|] [II|2]:12:Rich[ard|] [I|1] Rich[ard|] [I|1]:12:John John:13|12-13:Hen[ry|] [III|3] Hen[ry|] [III|3]:13:Ed[w[ard|]|] [I|1] Ed[w[ard|]|] [I|1]:13-14|13|14:Ed[w[ard|]|] [II|2] Ed[w[ard|]|] [II|2]:14:Ed[w[ard|]|] [III|3] Ed[w[ard|]|] [III|3]:14:Rich[ard|] [II|2] Rich[ard|] [II|2]:14:Hen[ry|] [IV|4] Part 1 Hen[ry|] [IV|4] Part 1:15|14-15:Hen[ry|] [IV|4] Part 2 Hen[ry|] [IV|4] Part 2:15|14-15:Hen[ry|] [V|5] Hen[ry|] [V|5]:15:Hen[ry|] [VI|6] Hen[ry|] [VI|6]:15:Ed[w[ard|]|] [IV|4] Ed[w[ard|]|] [IV|4]:15:Ed[w[ard|]|] [V|5] Ed[w[ard|]|] [V|5]:15:Rich[ard|] [III|3] Rich[ard|] [III|3]:15:Hen[ry|] [VII|7] Hen[ry|] [VII|7]:15-16|15|16:Hen[ry|] [VIII|8] Hen[ry|] [VIII|8]:16:Ed[w[ard|]|] [VI|6] Ed[w[ard|]|] [VI|6]:16:Mary Mary:16:Eliz[abeth|][ [I|1]|] Elizabeth[ [I|1]|]:16-17|16:Ja[me|]s [I|1] Ja[me|]s [I|1]:17:Cha[rle|]s [I|1] Cha[rle|]s [I|1]:17:[Oliver |]Cromwell [Oliver |]Cromwell:17:Rich[ard|] Cromwell Rich[ard|] Cromwell:17:Ch[arle|]s [II|2] Cha[rle|]s [II|2]:17:Ja[me|]s [II|2] Ja[me|]s [II|2]:17:W[illia|]m and Mary W[illia|]m and Mary:17-18|17:Anne Anne:18:Geo[rge|] [I|1] Geo[rge|] [I|1]:18:Geo[rge|] [II|2] Geo[rge|] [II|2]:18:Geo[rge|] [III|3] Geo[rge|] [III|3]:18-19|18|19:Geo[rge|] [IV|4] Geo[rge|] [IV|4]:19:W[illia|]m [IV|4] W[illia|]m [IV|4]:19:Victoria Victoria:19:Ed[w[ard|]|] [VII|7] Ed[w[ard|]|] [VII|7]:19-20|19|20:Geo[rge|] [V|5] Geo[rge|] [V|5]:20:Ed[w[ard|]|] [VIII|8] Ed[w[ard|]|] [VIII|8]:20:Geo[rge|] [VI|6] Geo[rge|] [VI|6]:20:Eliz[abeth|] [II|2] bsd-games-2.17/quiz/datfiles/Makefrag0000664000175000017500000000370406773402557016245 0ustar jsm28jsm28# Makefrag - makefile fragment for quiz/datfiles # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. quiz_datfiles_DIRS := $(QUIZ_DIR) quiz_datfiles_CATS := africa america areas arith asia babies bard chinese \ collectives ed elements europe flowers greek inca index latin \ locomotive midearth morse mult murders poetry posneg pres province \ seq-easy seq-hard sexes sov spell state trek ucc quiz_datfiles_all: quiz/datfiles/index quiz_datfiles_install: set -e; for c in $(quiz_datfiles_CATS); do $(INSTALL_DATA) quiz/datfiles/$$c $(INSTALL_PREFIX)$(QUIZ_DIR)/$$c; done bsd-games-2.17/quiz/datfiles/chinese0000664000175000017500000000021206363445554016134 0ustar jsm28jsm28rabbit:dragon dragon:snake snake:horse horse:sheep sheep:monkey monkey:rooster rooster:dog dog:boar boar:rat rat:ox ox:tiger tiger:rabbit bsd-games-2.17/quiz/Makefile.bsd0000664000175000017500000000105306701650657015211 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.13 1999/02/13 02:54:22 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 .include PROG= quiz MAN= quiz.6 SRCS= quiz.c rxp.c HIDEGAME=hidegame .if ${MKSHARE} != "no" CATS= africa america areas arith asia babies bard chinese collectives \ ed elements europe flowers greek inca index latin locomotive \ midearth morse mult murders poetry posneg pres province seq-easy \ seq-hard sexes sov spell state trek ucc FILES= ${CATS:S@^@${.CURDIR}/datfiles/@} FILESDIR=/usr/share/games/quiz.db .endif .include bsd-games-2.17/quiz/quiz.6.in0000664000175000017500000001007307767741711014475 0ustar jsm28jsm28.\" $NetBSD: quiz.6,v 1.10 2003/08/07 09:37:34 agc Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Jim R. Oldroyd at The Instruction Set. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)quiz.6 8.1 (Berkeley) 5/31/93 .\" .Dd May 31, 1993 .Dt QUIZ 6 .Os .Sh NAME .Nm quiz .Nd random knowledge tests .Sh SYNOPSIS .Nm .Op Fl t .Op Fl i Ar file .Op Ar question answer .Sh DESCRIPTION The .Nm utility tests your knowledge of random facts. It has a database of subjects from which you can choose. With no arguments, .Nm displays the list of available subjects. .Pp The options are as follows: .Bl -tag -width indent .It Fl t Use tutorial mode, in which questions are repeated later if you didn't get them right the first time, and new questions are presented less frequently to help you learn the older ones. .It Fl i Specify an alternative index file. .El .Pp Subjects are divided into categories. You can pick any two categories from the same subject. .Nm will ask questions from the first category and it expects answers from the second category. For example, the command .Dq quiz victim killer asks questions which are the names of victims, and expects you to answer with the cause of their untimely demise, whereas the command .Dq quiz killer victim works the other way around. .Pp If you get the answer wrong, .Nm lets you try again. To see the right answer, enter a blank line. .Ss Index and Data File Syntax The index and data files have a similar syntax. Lines in them consist of several categories separated by colons. The categories are regular expressions formed using the following meta-characters: .sp .Bl -tag -width "pat|pat" -compact -offset indent .It pat|pat alternative patterns .It {pat} optional pattern .It [pat] delimiters, as in pat[pat|pat]pat .El .Pp In an index file, each line represents a subject. The first category in each subject is the pathname of the data file for the subject. The remaining categories are regular expressions for the titles of each category in the subject. .Pp In data files, each line represents a question/answer set. Each category is the information for the question/answer for that category. .Pp The backslash character (``\e'') is used to quote syntactically significant characters, or at the end of a line to signify that a continuation line follows. .Pp If either a question or its answer is empty, .Nm will refrain from asking it. .Sh FILES .Bl -tag -width @quiz_dir@ -compact .It Pa @quiz_dir@ The default index and data files. .El .Sh BUGS .Nm is pretty cynical about certain subjects. bsd-games-2.17/quiz/quiz.c0000664000175000017500000002021210005547567014131 0ustar jsm28jsm28/* $NetBSD: quiz.c,v 1.20 2004/01/27 20:30:30 jsm Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Jim R. Oldroyd at The Instruction Set and Keith Gabryelski at * Commodore Business Machines. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95"; #else __RCSID("$NetBSD: quiz.c,v 1.20 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include "quiz.h" #include "pathnames.h" static QE qlist; static int catone, cattwo, tflag; static u_int qsize; char *appdstr(char *, const char *, size_t); void downcase(char *); void get_cats(char *, char *); void get_file(const char *); int main(int, char *[]); const char *next_cat(const char *); void quiz(void); void score(u_int, u_int, u_int); void show_index(void); void usage(void) __attribute__((__noreturn__)); int main(argc, argv) int argc; char *argv[]; { int ch; const char *indexfile; /* Revoke setgid privileges */ setregid(getgid(), getgid()); indexfile = _PATH_QUIZIDX; while ((ch = getopt(argc, argv, "i:t")) != -1) switch(ch) { case 'i': indexfile = optarg; break; case 't': tflag = 1; break; case '?': default: usage(); } argc -= optind; argv += optind; switch(argc) { case 0: get_file(indexfile); show_index(); break; case 2: get_file(indexfile); get_cats(argv[0], argv[1]); quiz(); break; default: usage(); } exit(0); } void get_file(file) const char *file; { FILE *fp; QE *qp; size_t len; char *lp; if ((fp = fopen(file, "r")) == NULL) err(1, "%s", file); /* * XXX * Should really free up space from any earlier read list * but there are no reverse pointers to do so with. */ qp = &qlist; qsize = 0; while ((lp = fgetln(fp, &len)) != NULL) { if (lp[len - 1] == '\n') lp[--len] = '\0'; if (qp->q_text && qp->q_text[strlen(qp->q_text) - 1] == '\\') qp->q_text = appdstr(qp->q_text, lp, len); else { if ((qp->q_next = malloc(sizeof(QE))) == NULL) errx(1, "malloc"); qp = qp->q_next; if ((qp->q_text = malloc(len + 1)) == NULL) errx(1, "malloc"); strncpy(qp->q_text, lp, len); qp->q_text[len] = '\0'; qp->q_asked = qp->q_answered = FALSE; qp->q_next = NULL; ++qsize; } } (void)fclose(fp); } void show_index() { QE *qp; const char *p, *s; FILE *pf; const char *pager; if (!isatty(1)) pager = "cat"; else { if (!(pager = getenv("PAGER")) || (*pager == 0)) pager = _PATH_PAGER; } if ((pf = popen(pager, "w")) == NULL) err(1, "%s", pager); (void)fprintf(pf, "Subjects:\n\n"); for (qp = qlist.q_next; qp; qp = qp->q_next) { for (s = next_cat(qp->q_text); s; s = next_cat(s)) { if (!rxp_compile(s)) errx(1, "%s", rxperr); if ((p = rxp_expand()) != NULL) (void)fprintf(pf, "%s ", p); } (void)fprintf(pf, "\n"); } (void)fprintf(pf, "\n%s\n%s\n%s\n", "For example, \"quiz victim killer\" prints a victim's name and you reply", "with the killer, and \"quiz killer victim\" works the other way around.", "Type an empty line to get the correct answer."); (void)pclose(pf); } void get_cats(cat1, cat2) char *cat1, *cat2; { QE *qp; int i; const char *s; downcase(cat1); downcase(cat2); for (qp = qlist.q_next; qp; qp = qp->q_next) { s = next_cat(qp->q_text); catone = cattwo = i = 0; while (s) { if (!rxp_compile(s)) errx(1, "%s", rxperr); i++; if (rxp_match(cat1)) catone = i; if (rxp_match(cat2)) cattwo = i; s = next_cat(s); } if (catone && cattwo && catone != cattwo) { if (!rxp_compile(qp->q_text)) errx(1, "%s", rxperr); get_file(rxp_expand()); return; } } errx(1, "invalid categories"); } void quiz() { QE *qp; int i; size_t len; u_int guesses, rights, wrongs; int next; char *answer, *t, question[LINE_SZ]; const char *s; srandom(time(NULL)); guesses = rights = wrongs = 0; for (;;) { if (qsize == 0) break; next = random() % qsize; qp = qlist.q_next; for (i = 0; i < next; i++) qp = qp->q_next; while (qp && qp->q_answered) qp = qp->q_next; if (!qp) { qsize = next; continue; } if (tflag && random() % 100 > 20) { /* repeat questions in tutorial mode */ while (qp && (!qp->q_asked || qp->q_answered)) qp = qp->q_next; if (!qp) continue; } s = qp->q_text; for (i = 0; i < catone - 1; i++) s = next_cat(s); if (!rxp_compile(s)) errx(1, "%s", rxperr); t = rxp_expand(); if (!t || *t == '\0') { qp->q_answered = TRUE; continue; } (void)strcpy(question, t); s = qp->q_text; for (i = 0; i < cattwo - 1; i++) s = next_cat(s); if (!rxp_compile(s)) errx(1, "%s", rxperr); t = rxp_expand(); if (!t || *t == '\0') { qp->q_answered = TRUE; continue; } qp->q_asked = TRUE; (void)printf("%s?\n", question); for (;; ++guesses) { if ((answer = fgetln(stdin, &len)) == NULL || answer[len - 1] != '\n') { score(rights, wrongs, guesses); exit(0); } answer[len - 1] = '\0'; downcase(answer); if (rxp_match(answer)) { (void)printf("Right!\n"); ++rights; qp->q_answered = TRUE; break; } if (*answer == '\0') { (void)printf("%s\n", t); ++wrongs; if (!tflag) qp->q_answered = TRUE; break; } (void)printf("What?\n"); } } score(rights, wrongs, guesses); } const char * next_cat(s) const char * s; { int esc; esc = 0; for (;;) switch (*s++) { case '\0': return (NULL); case '\\': esc = 1; break; case ':': if (!esc) return (s); default: esc = 0; break; } /* NOTREACHED */ } char * appdstr(s, tp, len) char *s; const char *tp; size_t len; { char *mp; const char *sp; int ch; char *m; if ((m = malloc(strlen(s) + len + 1)) == NULL) errx(1, "malloc"); for (mp = m, sp = s; (*mp++ = *sp++) != '\0'; ) ; --mp; if (*(mp - 1) == '\\') --mp; while ((ch = *mp++ = *tp++) && ch != '\n') ; *mp = '\0'; free(s); return (m); } void score(r, w, g) u_int r, w, g; { (void)printf("Rights %d, wrongs %d,", r, w); if (g) (void)printf(" extra guesses %d,", g); (void)printf(" score %d%%\n", (r + w + g) ? r * 100 / (r + w + g) : 0); } void downcase(p) char *p; { int ch; for (; (ch = *p) != '\0'; ++p) if (isascii(ch) && isupper(ch)) *p = tolower(ch); } void usage() { (void)fprintf(stderr, "quiz [-t] [-i file] category1 category2\n"); exit(1); } bsd-games-2.17/quiz/rxp.c0000664000175000017500000001575510005547567013772 0ustar jsm28jsm28/* $NetBSD: rxp.c,v 1.12 2004/01/27 20:30:30 jsm Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Jim R. Oldroyd at The Instruction Set and Keith Gabryelski at * Commodore Business Machines. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)rxp.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: rxp.c,v 1.12 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ /* * regular expression parser * * external functions and return values are: * rxp_compile(s) * TRUE success * FALSE parse failure; error message will be in char rxperr[] * metas are: * {...} optional pattern, equialent to [...|] * | alternate pattern * [...] pattern delimiters * * rxp_match(s) * TRUE string s matches compiled pattern * FALSE match failure or regexp error * * rxp_expand() * char * reverse-engineered regular expression string * NULL regexp error */ #include #include #include #include "quiz.h" /* regexp tokens, arg */ #define LIT (-1) /* literal character, char */ #define SOT (-2) /* start text anchor, - */ #define EOT (-3) /* end text anchor, - */ #define GRP_S (-4) /* start alternate grp, ptr_to_end */ #define GRP_E (-5) /* end group, - */ #define ALT_S (-6) /* alternate starts, ptr_to_next */ #define ALT_E (-7) /* alternate ends, - */ #define END (-8) /* end of regexp, - */ typedef short Rxp_t; /* type for regexp tokens */ static Rxp_t rxpbuf[RXP_LINE_SZ]; /* compiled regular expression buffer */ char rxperr[128]; /* parser error message */ static int rxp__compile(const char *, int); static char *rxp__expand(int); static int rxp__match(const char *, int, Rxp_t *, Rxp_t *, const char *); int rxp_compile(s) const char * s; { return (rxp__compile(s, TRUE)); } static int rxp__compile(s, first) const char *s; int first; { static Rxp_t *rp; static const char *sp; Rxp_t *grp_ptr; Rxp_t *alt_ptr; int esc, err; esc = 0; if (first) { rp = rxpbuf; sp = s; *rp++ = SOT; /* auto-anchor: pat is really ^pat$ */ *rp++ = GRP_S; /* auto-group: ^pat$ is really ^[pat]$ */ *rp++ = 0; } *rp++ = ALT_S; alt_ptr = rp; *rp++ = 0; for (; *sp; ++sp) { if (rp - rxpbuf >= RXP_LINE_SZ - 4) { (void)snprintf(rxperr, sizeof(rxperr), "regular expression too long %s", s); return (FALSE); } if (*sp == ':' && !esc) break; if (esc) { *rp++ = LIT; *rp++ = *sp; esc = 0; } else switch (*sp) { case '\\': esc = 1; break; case '{': case '[': *rp++ = GRP_S; grp_ptr = rp; *rp++ = 0; sp++; if ((err = rxp__compile(s, FALSE)) != TRUE) return (err); *rp++ = GRP_E; *grp_ptr = rp - rxpbuf; break; case '}': case ']': case '|': *rp++ = ALT_E; *alt_ptr = rp - rxpbuf; if (*sp != ']') { *rp++ = ALT_S; alt_ptr = rp; *rp++ = 0; } if (*sp != '|') { if (*sp != ']') { *rp++ = ALT_E; *alt_ptr = rp - rxpbuf; } if (first) { (void)snprintf(rxperr, sizeof(rxperr), "unmatched alternator in regexp %s", s); return (FALSE); } return (TRUE); } break; default: *rp++ = LIT; *rp++ = *sp; esc = 0; break; } } if (!first) { (void)snprintf(rxperr, sizeof(rxperr), "unmatched alternator in regexp %s", s); return (FALSE); } *rp++ = ALT_E; *alt_ptr = rp - rxpbuf; *rp++ = GRP_E; *(rxpbuf + 2) = rp - rxpbuf; *rp++ = EOT; *rp = END; return (TRUE); } /* * match string against compiled regular expression */ int rxp_match(s) const char * s; { return (rxp__match(s, TRUE, NULL, NULL, NULL)); } static int rxp__match(s, first, j_succ, j_fail, sp_fail) const char *s; int first; Rxp_t *j_succ; /* jump here on successful alt match */ Rxp_t *j_fail; /* jump here on failed match */ const char *sp_fail; /* reset sp to here on failed match */ { static Rxp_t *rp; static const char *sp; int ch; Rxp_t *grp_end = NULL; if (first) { rp = rxpbuf; sp = s; } while (rp < rxpbuf + RXP_LINE_SZ && *rp != END) switch(*rp) { case LIT: rp++; ch = isascii(*rp) && isupper(*rp) ? tolower(*rp) : *rp; if (ch != *sp++) { rp = j_fail; sp = sp_fail; return (FALSE); } rp++; break; case SOT: if (sp != s) return (FALSE); rp++; break; case EOT: if (*sp != 0) return (FALSE); rp++; break; case GRP_S: rp++; grp_end = rxpbuf + *rp++; break; case ALT_S: rp++; rxp__match(sp, FALSE, grp_end, rxpbuf + *rp++, sp); break; case ALT_E: rp = j_succ; return (TRUE); case GRP_E: rp = j_fail; sp = sp_fail; return (FALSE); default: abort(); } return (*rp != END ? FALSE : TRUE); } /* * Reverse engineer the regular expression, by picking first of all alternates. */ char * rxp_expand() { return (rxp__expand(TRUE)); } static char * rxp__expand(first) int first; { static char buf[RXP_LINE_SZ/2]; static Rxp_t *rp; static char *bp; Rxp_t *grp_ptr; char *err; if (first) { rp = rxpbuf; bp = buf; } while (rp < rxpbuf + RXP_LINE_SZ && *rp != END) switch(*rp) { case LIT: rp++; *bp++ = *rp++; break; case GRP_S: rp++; grp_ptr = rxpbuf + *rp; rp++; if ((err = rxp__expand(FALSE)) == NULL) return (err); rp = grp_ptr; break; case ALT_E: return (buf); case ALT_S: rp++; /* FALLTHROUGH */ case SOT: case EOT: case GRP_E: rp++; break; default: return (NULL); } if (first) { if (*rp != END) return (NULL); *bp = '\0'; } return (buf); } bsd-games-2.17/quiz/Makefrag0000664000175000017500000000331006773402557014443 0ustar jsm28jsm28# Makefrag - makefile fragment for quiz # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. quiz_DEFS := $(FGETLN_DEFS) quiz_DIRS := $(GAMESDIR) $(MAN6DIR) quiz_all: quiz/quiz quiz/quiz.6 quiz_install: quiz_all $(INSTALL_BINARY) quiz/quiz $(INSTALL_PREFIX)$(GAMESDIR)/quiz $(HIDE_GAME) quiz $(INSTALL_MANUAL) quiz/quiz.6 bsd-games-2.17/quiz/quiz.h0000664000175000017500000000463410005547567014150 0ustar jsm28jsm28/* $NetBSD: quiz.h,v 1.7 2004/01/27 20:30:30 jsm Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Jim R. Oldroyd at The Instruction Set and Keith Gabryelski at * Commodore Business Machines. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)quiz.h 8.1 (Berkeley) 5/31/93 */ #define TRUE 1 #define FALSE 0 /* Length of compiled regexp machine; increase if not big enough. */ #define RXP_LINE_SZ 8192 /* Maximum line length for data files. */ #define LINE_SZ 1024 /* Linked list for holding index and data file information. */ typedef struct qentry { struct qentry *q_next; /* next one */ char *q_text; /* category text string from file */ int q_asked; /* TRUE if question's been asked */ int q_answered; /* TRUE if question's been answered */ } QE; extern char rxperr[]; int rxp_compile(const char *); char *rxp_expand(void); int rxp_match(const char *); bsd-games-2.17/quiz/pathnames.h.in0000664000175000017500000000336007767741711015550 0ustar jsm28jsm28/* $NetBSD: pathnames.h,v 1.5 2003/08/07 09:37:34 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 5/31/93 */ #define _PATH_PAGER "@pager@" #define _PATH_QUIZIDX "@quiz_dir@/index" bsd-games-2.17/bcd/0000775000175000017500000000000010205246604012526 5ustar jsm28jsm28bsd-games-2.17/bcd/Makefile.bsd0000664000175000017500000000030106350047433014734 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.4 1995/03/21 15:08:10 cgd Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= bcd MAN= bcd.6 MLINKS= bcd.6 morse.6 bcd.6 ppt.6 HIDEGAME=hidegame .include bsd-games-2.17/bcd/bcd.c0000664000175000017500000001704410005547567013442 0ustar jsm28jsm28/* $NetBSD: bcd.c,v 1.13 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Steve Hayman of the Indiana University Computer Science Dept. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94"; #else __RCSID("$NetBSD: bcd.c,v 1.13 2004/01/27 20:30:29 jsm Exp $"); #endif #endif /* not lint */ /* * bcd -- * * Read one line of standard input and produce something that looks like a * punch card. An attempt to reimplement /usr/games/bcd. All I looked at * was the man page. * * I couldn't find a BCD table handy so I wrote a shell script to deduce what * the patterns were that the old bcd was using for each possible 8-bit * character. These are the results -- the low order 12 bits represent the * holes. (A 1 bit is a hole.) These may be wrong, but they match the old * program! * * Steve Hayman * sahayman@iuvax.cs.indiana.edu * 1989 11 30 * * * I found an error in the table. The same error is found in the SunOS 4.1.1 * version of bcd. It has apparently been around a long time. The error caused * 'Q' and 'R' to have the same punch code. I only noticed the error due to * someone pointing it out to me when the program was used to print a cover * for an APA! The table was wrong in 4 places. The other error was masked * by the fact that the input is converted to upper case before lookup. * * Dyane Bruce * db@diana.ocunix.on.ca * Nov 5, 1993 */ #include #include #include #include #include #include const u_short holes[256] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x206, 0x20a, 0x042, 0x442, 0x222, 0x800, 0x406, 0x812, 0x412, 0x422, 0xa00, 0x242, 0x400, 0x842, 0x300, 0x200, 0x100, 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, 0x002, 0x001, 0x012, 0x40a, 0x80a, 0x212, 0x00a, 0x006, 0x022, 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, 0x802, 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408, 0x404, 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208, 0x204, 0x202, 0x201, 0x082, 0x822, 0x600, 0x282, 0x30f, 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, 0x802, 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408, 0x404, 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208, 0x204, 0x202, 0x201, 0x082, 0x806, 0x822, 0x600, 0x282, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x206, 0x20a, 0x042, 0x442, 0x222, 0x800, 0x406, 0x812, 0x412, 0x422, 0xa00, 0x242, 0x400, 0x842, 0x300, 0x200, 0x100, 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, 0x002, 0x001, 0x012, 0x40a, 0x80a, 0x212, 0x00a, 0x006, 0x022, 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, 0x802, 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408, 0x404, 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208, 0x204, 0x202, 0x201, 0x082, 0x806, 0x822, 0x600, 0x282, 0x30f, 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, 0x802, 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408, 0x404, 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208, 0x204, 0x202, 0x201, 0x082, 0x806, 0x822, 0x600, 0x282, 0x0 }; /* * i'th bit of w. */ #define bit(w,i) ((w)&(1<<(i))) int main(int, char *[]); void printcard(unsigned char *); int main(argc, argv) int argc; char **argv; { char cardline[80]; /* revoke setgid privileges */ setregid(getgid(), getgid()); /* * The original bcd prompts with a "%" when reading from stdin, * but this seems kind of silly. So this one doesn't. */ if (argc > 1) { while (--argc) printcard((unsigned char *)*++argv); } else while (fgets(cardline, sizeof(cardline), stdin)) printcard((unsigned char *)cardline); exit(0); } #define COLUMNS 48 void printcard(str) unsigned char *str; { static const char rowchars[] = " 123456789"; int i, row; unsigned char *p; /* ruthlessly remove newlines and truncate at 48 characters. */ if ((p = (unsigned char *)strchr((char *)str, '\n'))) *p = '\0'; if (strlen((char *)str) > COLUMNS) str[COLUMNS] = '\0'; /* make string upper case. */ for (p = str; *p; ++p) if (isascii(*p) && islower(*p)) *p = toupper(*p); /* top of card */ putchar(' '); for (i = 1; i <= COLUMNS; ++i) putchar('_'); putchar('\n'); /* * line of text. Leave a blank if the character doesn't have * a hole pattern. */ p = str; putchar('/'); for (i = 1; *p; i++, p++) if (holes[(int)*p]) putchar(*p); else putchar(' '); while (i++ <= COLUMNS) putchar(' '); putchar('|'); putchar('\n'); /* * 12 rows of potential holes; output a ']', which looks kind of * like a hole, if the appropriate bit is set in the holes[] table. * The original bcd output a '[', a backspace, five control A's, * and then a ']'. This seems a little excessive. */ for (row = 0; row <= 11; ++row) { putchar('|'); for (i = 0, p = str; *p; i++, p++) { if (bit(holes[(int)*p], 11 - row)) putchar(']'); else putchar(rowchars[row]); } while (i++ < COLUMNS) putchar(rowchars[row]); putchar('|'); putchar('\n'); } /* bottom of card */ putchar('|'); for (i = 1; i <= COLUMNS; i++) putchar('_'); putchar('|'); putchar('\n'); } bsd-games-2.17/bcd/bcd.60000664000175000017500000000553507767741711013377 0ustar jsm28jsm28.\" $NetBSD: bcd.6,v 1.16 2003/08/07 09:37:04 agc Exp $ .\" .\" Copyright (c) 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)bcd.6 8.1 (Berkeley) 5/31/93 .\" .Dd November 26, 2002 .Dt BCD 6 .Os .Sh NAME .Nm bcd , .Nm ppt , .Nm morse .Nd "reformat input as punch cards, paper tape or morse code" .Sh SYNOPSIS .Nm .Op Ar string ... .Nm ppt .Op Fl d Ns \&| Ns Ar string ... .Nm morse .Op Fl ds Ar string ... .Sh DESCRIPTION The .Nm , .Nm ppt and .Nm morse commands read the given input and reformat it in the form of punched cards, paper tape or morse code respectively. Acceptable input are command line arguments or the standard input. .Pp Available option: .Bl -tag -width flag .It Fl s The .Fl s option for morse produces dots and dashes rather than words. .It Fl d Decode .Nm ppt output, or .Nm morse output consisting of dots and slashes (as generated by using the .Fl s option). .El .Sh SEE ALSO .Rs .%B "ISO 1681:1973: Information processing--Unpunched paper cards--Specification" .Re .Rs .%B "ISO 1682:1973: Information processing--80 columns punched paper cards--Dimensions and location of rectangular punched holes" .Re .Rs .%B "ECMA-10: ECMA Standard for Data Interchange on Punched Tape" .Re .Rs .%B "ITU-T Recommendation F.1: Operational provisions for the international public telegram service" .%O "Division B, I. Morse code" .Re bsd-games-2.17/bcd/Makefrag0000664000175000017500000000323506773402557014211 0ustar jsm28jsm28# Makefrag - makefile fragment for bcd # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. bcd_DIRS := $(GAMESDIR) $(MAN6DIR) bcd_all: bcd/bcd bcd/bcd.6 bcd_install: bcd_all $(INSTALL_BINARY) bcd/bcd $(INSTALL_PREFIX)$(GAMESDIR)/bcd $(HIDE_GAME) bcd $(INSTALL_MANUAL) bcd/bcd.6 bsd-games-2.17/THANKS0000664000175000017500000000505610005516724012720 0ustar jsm28jsm28Credits and acknowledgements for bsd-games and bsd-games-non-free ================================================================= For details of authors of the games and maintenance of the bsd-games and bsd-games-non-free packages, see AUTHORS. The following are further credits for people who have helped improve the package; thanks also to those who have reported bugs and so helped us improve the package, and to those who have similarly contributed to the games in *BSD over the years. Please help me to repair any errors or omissions in this list. For recent work (since 1.3), thanks to: David A Bagley For work towards portability to Cygwin. Joey Hess For the Debian patches, which covered what was needed to make the games compile with current libraries, provided many bug fixes and showed where I needed to do things like parametrise manpages. Also many other bug reports and fixes, and manpages for wargames and paranoia. David Frey For the ports of tetris and gomoku. Bill Lash For tracking down and fixing a bug in rogue. Paul Janzen For work on the OpenBSD games, including supplying improvements that could be applied to the Linux port, and merging NetBSD changes into OpenBSD so making it easier to extract his and other OpenBSD changes to include in the Linux port. Also for checking the licence of boggle, so it could be included in the main bsd-games package. Hubert Feyrer For timely responses to my NetBSD PRs, merging the Linux changes back into NetBSD. Also for sponsoring me to be a NetBSD developer, and for general assistance in the merge. Stuart Lamble For a bug report and analysis (with patch) about scoring in backgammon. Malcolm Parsons For several bug reports and fixes. For the original bsd-games package (versions up to 1.3): Special Thanks to: Andy Tefft (teffta@engr.dnet.ge.com) For porting backgammon, canfield, fortune, and number. Andy also was a big help in organizing this project, and in getting the ball rolling in the early stages. Thanks also to: Ross Becker (beckerr@pyrite.som.cwru.edu) - working on hunt. jyanowit@orixa.mtholyoke.edu - backgammon bug fix. Andrew Kuchling (fnord@binkley.cs.mcgill.ca) - bog bug fix. Rik Faith (faith@cs.unc.edu) - words file for hangman and bog. For authors and acknowledgements for the original BSD games, see AUTHORS. Local Variables: mode: text End: bsd-games-2.17/exec.objs0000664000175000017500000001441110204250367013602 0ustar jsm28jsm28# exec.objs - details of objects that go into bsd-games programs. # This file is used for automatic makefile generation. # # Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004, 2005 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # adventure crc.o data.o done.o init.o io.o main.o save.o subr.o \ vocab.o wizard.o adventure/setup setup.o arithmetic arithmetic.o lib/getprogname.o atc extern.o grammar.o graphics.o input.o lex.o list.o \ log.o main.o tunable.o update.o lib/strlcpy.o backgammon/backgammon/backgammon extra.o main.o move.o text.o \ version.o backgammon/common_source/allow.o \ backgammon/common_source/board.o backgammon/common_source/check.o \ backgammon/common_source/fancy.o backgammon/common_source/init.o \ backgammon/common_source/odds.o backgammon/common_source/one.o \ backgammon/common_source/save.o backgammon/common_source/subs.o \ backgammon/common_source/table.o backgammon/teachgammon/teachgammon data.o teach.o ttext1.o ttext2.o \ tutor.o backgammon/common_source/allow.o \ backgammon/common_source/board.o backgammon/common_source/check.o \ backgammon/common_source/fancy.o backgammon/common_source/init.o \ backgammon/common_source/one.o backgammon/common_source/save.o \ backgammon/common_source/subs.o backgammon/common_source/table.o banner banner.o battlestar battlestar.o command1.o command2.o command3.o \ command4.o command5.o command6.o command7.o cypher.o dayfile.o \ dayobjs.o fly.o getcom.o globals.o init.o misc.o nightfile.o \ nightobjs.o parse.o room.o save.o words.o lib/fgetln.o bcd bcd.o boggle/boggle/boggle bog.o help.o mach.o prtable.o timer.o word.o boggle/mkdict/mkdict mkdict.o boggle/mkindex/mkindex mkindex.o caesar caesar.o canfield/canfield/canfield canfield.o canfield/cfscores/cfscores cfscores.o cribbage cards.o crib.o extern.o instr.o io.o score.o support.o dab algor.o board.o box.o gamescreen.o human.o main.o \ player.o random.o ttyscrn.o dm dm.o utmpentry.o lib/getloadavg.o factor factor.o primes/pr_tbl.o fish fish.o fortune/fortune/fortune fortune.o lib/getprogname.o fortune/strfile/strfile strfile.o fortune/unstr/unstr unstr.o gomoku bdinit.o bdisp.o main.o makemove.o pickmove.o stoc.o hack alloc.o hack.Decl.o hack.apply.o hack.bones.o hack.o \ hack.cmd.o hack.do.o hack.do_name.o hack.do_wear.o hack.dog.o \ hack.eat.o hack.end.o hack.engrave.o hack.fight.o hack.invent.o \ hack.ioctl.o hack.lev.o hack.main.o hack.makemon.o hack.mhitu.o \ hack.mklev.o hack.mkmaze.o hack.mkobj.o hack.mkshop.o hack.mon.o \ hack.monst.o hack.o_init.o hack.objnam.o hack.options.o hack.pager.o \ hack.potion.o hack.pri.o hack.read.o hack.rip.o hack.rumors.o \ hack.save.o hack.search.o hack.shk.o hack.shknam.o hack.steal.o \ hack.termcap.o hack.timeout.o hack.topl.o hack.track.o hack.trap.o \ hack.tty.o hack.u_init.o hack.unix.o hack.vault.o hack.version.o \ hack.wield.o hack.wizard.o hack.worm.o hack.worn.o hack.zap.o rnd.o hack/makedefs makedefs.o hangman endgame.o extern.o getguess.o getword.o main.o \ playgame.o prdata.o prman.o prword.o setup.o hunt/hunt/hunt connect.o hunt.o otto.o playit.o \ hunt/huntd/pathname.o hunt/huntd/huntd answer.o ctl.o ctl_transact.o draw.o driver.o \ execute.o expl.o extern.o faketalk.o get_names.o makemaze.o \ pathname.o shots.o terminal.o mille comp.o end.o extern.o init.o mille.o misc.o move.o \ print.o roll.o save.o types.o varpush.o monop cards.o execute.o getinp.o houses.o jail.o misc.o \ monop.o morg.o print.o prop.o rent.o roll.o spec.o trade.o monop/initdeck initdeck.o morse morse.o number number.o phantasia fight.o gamesupport.o interplayer.o io.o main.o \ misc.o phantglobs.o phantasia/setup phantglobs.o setup.o pig pig.o pom pom.o ppt ppt.o primes pattern.o pr_tbl.o primes.o quiz quiz.o rxp.o lib/fgetln.o rain rain.o lib/getprogname.o random random.o robots auto.o extern.o flush_in.o init_field.o main.o \ make_level.o move.o move_robs.o play_level.o query.o rnd_pos.o score.o rogue hit.o init.o inventory.o level.o machdep.o main.o \ message.o monster.o move.o object.o pack.o play.o random.o ring.o \ room.o save.o score.o spec_hit.o throw.o trap.o use.o zap.o \ lib/strlcpy.o sail assorted.o game.o globals.o dr_1.o dr_2.o dr_3.o \ dr_4.o dr_5.o dr_main.o lo_main.o main.o misc.o parties.o pl_1.o \ pl_2.o pl_3.o pl_4.o pl_5.o pl_6.o pl_7.o pl_main.o sync.o version.o \ lib/strlcpy.o snake/snake/snake snake.o snake/snscore/snscore snscore.o tetris input.o scores.o screen.o shapes.o tetris.o trek abandon.o attack.o autover.o capture.o cgetc.o \ check_out.o checkcond.o compkl.o computer.o damage.o damaged.o \ dcrept.o destruct.o dock.o dumpgame.o dumpme.o dumpssradio.o events.o \ externs.o getcodi.o getpar.o help.o impulse.o initquad.o kill.o \ klmove.o lose.o lrscan.o main.o move.o nova.o out.o phaser.o play.o \ ram.o ranf.o rest.o schedule.o score.o setup.o setwarp.o shield.o \ snova.o srscan.o systemname.o torped.o visual.o warp.o win.o worm worm.o worms worms.o wump wump.o bsd-games-2.17/AUTHORS0000664000175000017500000000565207413425047013065 0ustar jsm28jsm28Authors of bsd-games and bsd-games-non-free =========================================== The bsd-games package was originally created by Curt Olson and Andy Tefft . The games themselves were written by many contributers to *BSD over the past twenty years or so. Maintenance of the package was passed to me in 1997; I divided it into bsd-games and bsd-games-non-free according to the established (DFSG/OSD) definition, following the division used for the Debian package of 1.3. Much of the packaging has been written or extensively modified by myself. Joey Hess wrote the manpages for wargames and paranoia. Based on the source and manpages, here are the details of the people who originally wrote the games over more than 20 years. Many of the email addresses below are probably no longer valid. Please send any further information you have to help improve this list. adventure: Will Crowther, Don Woods; C port by Jim Gilloghy arithmetic: Eamonn McManus atc: Ed James backgammon: Alan Char banner: Mark Horton battlestar: David Riggle , with acknowledgements to Chris Guthrie , Peter Da Silva, Kevin Brown, Edward Wang , Ken Arnold & Company bcd: Steve Hayman boggle: Barry Brachman caesar: Rick Adams, Stan King, John Eldridge, based on algorithm suggested by Bob Morris canfield: Steve Levine; further random hacking by Steve Feldman, Kirk McKusick, Mikey Olson, Eric Allman countmail: Charles M. Hannum cribbage: Earl T. Cohen, Ken Arnold dm: (unknown) factor: Landon Curt Noll fish: Muffy Barkocy fortune: Ken Arnold (fortunes from many sources) gomoku: Ralph Campbell (with acknowledgement to Peter Langston) hack: Originally Jay Fenlason, with help from Kenny Woodland, Mike Thome and Jon Payne; this version almost entirely rewritten by Andries Brouwer . hangman: Ken Arnold hunt: Conrad Huang , Greg Couch mille: Ken Arnold monop: Ken Arnold morse: (unknown) number: (unknown) phantasia: Edward Estes , with thanks to Chris Robertson pig: (unknown) pom: Keith E. Brandt ppt: (unknown) primes: Landon Curt Noll quiz: Jim R. Oldroyd rain: Eric P. Scott random: Guy Harris robots: Ken Arnold, Christos Zoulas rogue: Timothy Stoehr, Michael C. Toy, Kenneth C. R. C. Arnold, Glenn Wichman sail: Dave Riggle , Ed Wang ; Craig Leres, Chris Guthrie snake: (unknown) tetris: Nancy L. Tinkham, Darren F. Provine, Chris Torek trek: Eric Allman wargames: (unknown) worm: Michael Toy worms: Eric P. Scott wtf: Allen Briggs wump: Dave Taylor Local Variables: mode: text End: bsd-games-2.17/fish/0000775000175000017500000000000010205246604012727 5ustar jsm28jsm28bsd-games-2.17/fish/pathnames.h.in0000664000175000017500000000335507767741711015515 0ustar jsm28jsm28/* $NetBSD: pathnames.h,v 1.4 2003/08/07 09:37:13 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 5/31/93 */ #define _PATH_INSTR "@fish_instrfile@" #define _PATH_MORE "@pager@" bsd-games-2.17/fish/Makefile.bsd0000664000175000017500000000040306701650657015150 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.10 1999/02/13 02:54:21 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 .include PROG= fish MAN= fish.6 HIDEGAME=hidegame .if ${MKSHARE} != "no" FILES=fish.instr FILESDIR=/usr/share/games .endif .include bsd-games-2.17/fish/fish.instr0000664000175000017500000000303605462615006014750 0ustar jsm28jsm28This is the traditional children's card game "Go Fish". We each get seven cards, and the rest of the deck is kept to be drawn from later. The object of the game is to collect "books", or all of the cards of a single value. For example, getting four 2's would give you a "book of 2's". We take turns asking each other for cards, but you can't ask me for a card value if you don't have one of them in your hand! If I have any cards of the value you ask for, I have to give them to you. As long as I have one of the cards you ask for, you get to keep asking. If you ask me for a card of which I don't have any, then I'll tell you to "Go Fish!" This means that you draw a card from the deck. If you draw the card you asked me for, you get to keep asking me for cards. If not, it's my turn and I ask you for a card. Sometimes you get to ask first, sometimes I do. I'll tell you when it's your turn to move, I'll draw cards from the deck for you, and I'll tell you what you have in your hand. (Don't worry, I don't look at your hand when I'm trying to decide what card to ask for, honest!) Your input can be a card name ("A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q" or "K") or the letter "p", or "quit". The letter "p" makes my game much smarter, and the line "quit" stops the game. Just hitting the carriage return key displays how many cards I have in my hand, how many are left in the deck, and which books I've gotten. Normally, the game stops when one of us runs out of cards, and the winner is whoever has the most books! Good luck! bsd-games-2.17/fish/fish.c0000664000175000017500000002407410204563462014036 0ustar jsm28jsm28/* $NetBSD: fish.c,v 1.16 2005/02/15 12:56:20 jsm Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Muffy Barkocy. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: fish.c,v 1.16 2005/02/15 12:56:20 jsm Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include "pathnames.h" #define RANKS 13 #define HANDSIZE 7 #define CARDS 4 #define TOTCARDS RANKS * CARDS #define USER 1 #define COMPUTER 0 #define OTHER(a) (1 - (a)) const char *const cards[] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", NULL, }; #define PRC(card) (void)printf(" %s", cards[card]) int promode; int asked[RANKS], comphand[RANKS], deck[TOTCARDS]; int userasked[RANKS], userhand[RANKS]; int curcard = TOTCARDS; void chkwinner(int, const int *); int compmove(void); int countbooks(const int *); int countcards(const int *); int drawcard(int, int *); int gofish(int, int, int *); void goodmove(int, int, int *, int *); void init(void); void instructions(void); int main(int, char *[]); int nrandom(int); void printhand(const int *); void printplayer(int); int promove(void); void usage(void) __attribute__((__noreturn__)); int usermove(void); int main(argc, argv) int argc; char **argv; { int ch, move; /* Revoke setgid privileges */ setregid(getgid(), getgid()); while ((ch = getopt(argc, argv, "p")) != -1) switch(ch) { case 'p': promode = 1; break; case '?': default: usage(); } srandom(time((time_t *)NULL)); instructions(); init(); if (nrandom(2) == 1) { printplayer(COMPUTER); (void)printf("get to start.\n"); goto istart; } printplayer(USER); (void)printf("get to start.\n"); for (;;) { move = usermove(); if (!comphand[move]) { if (gofish(move, USER, userhand)) continue; } else { goodmove(USER, move, userhand, comphand); continue; } istart: for (;;) { move = compmove(); if (!userhand[move]) { if (!gofish(move, COMPUTER, comphand)) break; } else goodmove(COMPUTER, move, comphand, userhand); } } /* NOTREACHED */ } int usermove() { int n; const char *const *p; char buf[256]; (void)printf("\nYour hand is:"); printhand(userhand); for (;;) { (void)printf("You ask me for: "); (void)fflush(stdout); if (fgets(buf, sizeof(buf), stdin) == NULL) exit(0); if (buf[0] == '\0') continue; if (buf[0] == '\n') { (void)printf("%d cards in my hand, %d in the pool.\n", countcards(comphand), curcard); (void)printf("My books:"); (void)countbooks(comphand); continue; } buf[strlen(buf) - 1] = '\0'; if (!strcasecmp(buf, "p") && !promode) { promode = 1; (void)printf("Entering pro mode.\n"); continue; } if (!strcasecmp(buf, "quit")) exit(0); for (p = cards; *p; ++p) if (!strcasecmp(*p, buf)) break; if (!*p) { (void)printf("I don't understand!\n"); continue; } n = p - cards; if (userhand[n]) { userasked[n] = 1; return(n); } if (nrandom(3) == 1) (void)printf("You don't have any of those!\n"); else (void)printf("You don't have any %s's!\n", cards[n]); if (nrandom(4) == 1) (void)printf("No cheating!\n"); (void)printf("Guess again.\n"); } /* NOTREACHED */ } int compmove() { static int lmove; if (promode) lmove = promove(); else { do { lmove = (lmove + 1) % RANKS; } while (!comphand[lmove] || comphand[lmove] == CARDS); } asked[lmove] = 1; (void)printf("I ask you for: %s.\n", cards[lmove]); return(lmove); } int promove() { int i, max; for (i = 0; i < RANKS; ++i) if (userasked[i] && comphand[i] > 0 && comphand[i] < CARDS) { userasked[i] = 0; return(i); } if (nrandom(3) == 1) { for (i = 0;; ++i) if (comphand[i] && comphand[i] != CARDS) { max = i; break; } while (++i < RANKS) if (comphand[i] != CARDS && comphand[i] > comphand[max]) max = i; return(max); } if (nrandom(1024) == 0723) { for (i = 0; i < RANKS; ++i) if (userhand[i] && comphand[i]) return(i); } for (;;) { for (i = 0; i < RANKS; ++i) if (comphand[i] && comphand[i] != CARDS && !asked[i]) return(i); for (i = 0; i < RANKS; ++i) asked[i] = 0; } /* NOTREACHED */ } int drawcard(player, hand) int player; int *hand; { int card; ++hand[card = deck[--curcard]]; if (player == USER || hand[card] == CARDS) { printplayer(player); (void)printf("drew %s", cards[card]); if (hand[card] == CARDS) { (void)printf(" and made a book of %s's!\n", cards[card]); chkwinner(player, hand); } else (void)printf(".\n"); } return(card); } int gofish(askedfor, player, hand) int askedfor, player; int *hand; { printplayer(OTHER(player)); (void)printf("say \"GO FISH!\"\n"); if (askedfor == drawcard(player, hand)) { printplayer(player); (void)printf("drew the guess!\n"); printplayer(player); (void)printf("get to ask again!\n"); return(1); } return(0); } void goodmove(player, move, hand, opphand) int player, move; int *hand, *opphand; { printplayer(OTHER(player)); (void)printf("have %d %s%s.\n", opphand[move], cards[move], opphand[move] == 1 ? "": "'s"); hand[move] += opphand[move]; opphand[move] = 0; if (hand[move] == CARDS) { printplayer(player); (void)printf("made a book of %s's!\n", cards[move]); chkwinner(player, hand); } chkwinner(OTHER(player), opphand); printplayer(player); (void)printf("get another guess!\n"); } void chkwinner(player, hand) int player; const int *hand; { int cb, i, ub; for (i = 0; i < RANKS; ++i) if (hand[i] > 0 && hand[i] < CARDS) return; printplayer(player); (void)printf("don't have any more cards!\n"); (void)printf("My books:"); cb = countbooks(comphand); (void)printf("Your books:"); ub = countbooks(userhand); (void)printf("\nI have %d, you have %d.\n", cb, ub); if (ub > cb) { (void)printf("\nYou win!!!\n"); if (nrandom(1024) == 0723) (void)printf("Cheater, cheater, pumpkin eater!\n"); } else if (cb > ub) { (void)printf("\nI win!!!\n"); if (nrandom(1024) == 0723) (void)printf("Hah! Stupid peasant!\n"); } else (void)printf("\nTie!\n"); exit(0); } void printplayer(player) int player; { switch (player) { case COMPUTER: (void)printf("I "); break; case USER: (void)printf("You "); break; } } void printhand(hand) const int *hand; { int book, i, j; for (book = i = 0; i < RANKS; i++) if (hand[i] < CARDS) for (j = hand[i]; --j >= 0;) PRC(i); else ++book; if (book) { (void)printf(" + Book%s of", book > 1 ? "s" : ""); for (i = 0; i < RANKS; i++) if (hand[i] == CARDS) PRC(i); } (void)putchar('\n'); } int countcards(hand) const int *hand; { int i, count; for (count = i = 0; i < RANKS; i++) count += *hand++; return(count); } int countbooks(hand) const int *hand; { int i, count; for (count = i = 0; i < RANKS; i++) if (hand[i] == CARDS) { ++count; PRC(i); } if (!count) (void)printf(" none"); (void)putchar('\n'); return(count); } void init() { int i, j, temp; for (i = 0; i < TOTCARDS; ++i) deck[i] = i % RANKS; for (i = 0; i < TOTCARDS - 1; ++i) { j = nrandom(TOTCARDS-i); if (j == 0) continue; temp = deck[i]; deck[i] = deck[i+j]; deck[i+j] = temp; } for (i = 0; i < HANDSIZE; ++i) { ++userhand[deck[--curcard]]; ++comphand[deck[--curcard]]; } } int nrandom(n) int n; { return((int)random() % n); } void instructions() { int input; pid_t pid; int fd; const char *pager; int status; (void)printf("Would you like instructions (y or n)? "); input = getchar(); while (getchar() != '\n'); if (input != 'y') return; switch (pid = fork()) { case 0: /* child */ if (!isatty(1)) pager = "cat"; else { if (!(pager = getenv("PAGER")) || (*pager == 0)) pager = _PATH_MORE; } if ((fd = open(_PATH_INSTR, O_RDONLY)) == -1) err(1, "open %s", _PATH_INSTR); if (dup2(fd, 0) == -1) err(1, "dup2"); (void)execl("/bin/sh", "sh", "-c", pager, (char *) NULL); err(1, "exec sh -c %s", pager); /*NOTREACHED*/ case -1: err(1, "fork"); /*NOTREACHED*/ default: (void)waitpid(pid, &status, 0); break; } (void)printf("Hit return to continue...\n"); while ((input = getchar()) != EOF && input != '\n'); } void usage() { (void)fprintf(stderr, "usage: fish [-p]\n"); exit(1); } bsd-games-2.17/fish/Makefrag0000664000175000017500000000343506773402557014414 0ustar jsm28jsm28# Makefrag - makefile fragment for fish # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. fish_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(FISH_INSTRFILE)) fish_all: fish/fish fish/fish.instr fish/fish.6 fish_install: fish_all $(INSTALL_BINARY) fish/fish $(INSTALL_PREFIX)$(GAMESDIR)/fish $(HIDE_GAME) fish $(INSTALL_DATA) fish/fish.instr $(INSTALL_PREFIX)$(FISH_INSTRFILE) $(INSTALL_MANUAL) fish/fish.6 bsd-games-2.17/fish/fish.60000664000175000017500000000635607767741711014003 0ustar jsm28jsm28.\" $NetBSD: fish.6,v 1.8 2003/08/07 09:37:13 agc Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)fish.6 8.1 (Berkeley) 5/31/93 .\" .Dd May 31, 1993 .Dt FISH 6 .Os .Sh NAME .Nm fish .Nd play .Dq Go Fish .Sh SYNOPSIS .Nm .Op Fl p .Sh DESCRIPTION .Nm is the game .Dq Go Fish , a traditional children's card game. .Pp The computer deals the player and itself seven cards, and places the rest of the deck face-down (figuratively). The object of the game is to collect .Dq books , or all of the members of a single rank. For example, collecting four 2's would give the player a .Dq book of 2's . .Pp The options are as follows: .Bl -tag -width indent .It Fl p Professional mode. .El .Pp The computer makes a random decision as to who gets to start the game, and then the computer and player take turns asking each other for cards of a specified rank. If the asked player has any cards of the requested rank, they give them up to the asking player. A player must have at least one of the cards of the rank they request in their hand. When a player asks for a rank of which the other player has no cards, the asker is told to .Dq Go Fish! . Then, the asker draws a card from the non-dealt cards. If they draw the card they asked for, they continue their turn, asking for more ranks from the other player. Otherwise, the other player gets a turn. .Pp When a player completes a book, either by getting cards from the other player or drawing from the deck, they set those cards aside and the rank is no longer in play. .Pp The game ends when either player no longer has any cards in their hand. The player with the most books wins. .Pp .Nm provides instructions as to what input it accepts. .Sh BUGS The computer cheats only rarely. bsd-games-2.17/install-man.in0000775000175000017500000000610007250165574014561 0ustar jsm28jsm28# install-man.in - install a manpage. # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. set -e if [ $# = 1 ]; then page=$1 basepage=$(basename "$page") section=${basepage##*.} if [ "$section" = 6 ]; then mandir=@install_prefix@@man6dir@ elif [ "$section" = 8 ]; then mandir=@install_prefix@@man8dir@ elif [ "$section" = 5 ]; then mandir=@install_prefix@@man5dir@ else echo "Unknown manpage section $section" >&2 exit 1 fi @install_manpage@ "$page" "$mandir/$basepage" if [ @gzip_manpages@ = y ]; then rm -f "$mandir/$basepage.gz" gzip -9 "$mandir/$basepage" fi elif [ $# = 2 ]; then # Manpage 2 should link to manpage 1. No complications of removing # directories from their names. page1=$1 section1=${page1##*.} page2=$2 section2=${page2##*.} if [ "$section2" = 6 ]; then mandir=@install_prefix@@man6dir@ elif [ "$section2" = 8 ]; then mandir=@install_prefix@@man8dir@ elif [ "$section2" = 5 ]; then mandir=@install_prefix@@man5dir@ else echo "Unknown manpage section $section2" >&2 exit 1 fi if [ @use_dot_so@ = .so ]; then echo ".so man$section1/$page1" >"$mandir/$page2" chmod @manpage_perms@ "$mandir/$page2" if [ @do_chown@ = y ]; then chown @manpage_owner@:@manpage_group@ "$mandir/$page2" fi if [ @gzip_manpages@ = y ]; then rm -f "$mandir/$page2.gz" gzip -9 "$mandir/$page2" fi else if [ "$section1" = "$section2" ]; then linkto="$page1" else linkto="../man$section1/$page1" fi if [ @gzip_manpages@ = y ]; then ln -sf "$linkto.gz" "$mandir/$page2.gz" else ln -sf "$linkto" "$mandir/$page2" fi fi else echo "usage: $0 manpage [ manpage ]" >&2 exit 1 fi bsd-games-2.17/caesar/0000775000175000017500000000000010205246604013234 5ustar jsm28jsm28bsd-games-2.17/caesar/Makefile.bsd0000664000175000017500000000033306350047433015447 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.6 1997/03/24 22:15:40 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= caesar MAN= caesar.6 DPADD= ${LIBM} LDADD= -lm MLINKS= caesar.6 rot13.6 SCRIPTS=rot13.sh .include bsd-games-2.17/caesar/caesar.c0000664000175000017500000001054510005547567014655 0ustar jsm28jsm28/* $NetBSD: caesar.c,v 1.14 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Rick Adams. * * Authors: * Stan King, John Eldridge, based on algorithm suggested by * Bob Morris * 29-Sep-82 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)caesar.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: caesar.c,v 1.14 2004/01/27 20:30:29 jsm Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include #define LINELENGTH 2048 #define ROTATE(ch, perm) \ isupper(ch) ? ('A' + (ch - 'A' + perm) % 26) : \ islower(ch) ? ('a' + (ch - 'a' + perm) % 26) : ch /* * letter frequencies (taken from some unix(tm) documentation) * (unix is a trademark of Bell Laboratories) */ double stdf[26] = { 7.97, 1.35, 3.61, 4.78, 12.37, 2.01, 1.46, 4.49, 6.39, 0.04, 0.42, 3.81, 2.69, 5.92, 6.96, 2.91, 0.08, 6.63, 8.77, 9.68, 2.62, 0.81, 1.88, 0.23, 2.07, 0.06, }; int main(int, char *[]); void printit(const char *) __attribute__((__noreturn__)); int main(argc, argv) int argc; char **argv; { int ch, i, nread; double dot, winnerdot; char *inbuf; int obs[26], try, winner; /* revoke setgid privileges */ setregid(getgid(), getgid()); winnerdot = 0; if (argc > 1) printit(argv[1]); if (!(inbuf = malloc(LINELENGTH))) err(1, NULL); /* adjust frequency table to weight low probs REAL low */ for (i = 0; i < 26; ++i) stdf[i] = log(stdf[i]) + log(26.0 / 100.0); /* zero out observation table */ memset(obs, 0, 26 * sizeof(int)); if ((nread = read(STDIN_FILENO, inbuf, LINELENGTH)) < 0) err(1, "reading from stdin"); for (i = nread; i--;) { ch = inbuf[i]; if (islower(ch)) ++obs[ch - 'a']; else if (isupper(ch)) ++obs[ch - 'A']; } /* * now "dot" the freqs with the observed letter freqs * and keep track of best fit */ for (try = winner = 0; try < 26; ++try) { /* += 13) { */ dot = 0; for (i = 0; i < 26; i++) dot += obs[i] * stdf[(i + try) % 26]; /* initialize winning score */ if (try == 0) winnerdot = dot; if (dot > winnerdot) { /* got a new winner! */ winner = try; winnerdot = dot; } } for (;;) { for (i = 0; i < nread; ++i) { ch = inbuf[i]; putchar(ROTATE(ch, winner)); } if (nread < LINELENGTH) break; if ((nread = read(STDIN_FILENO, inbuf, LINELENGTH)) < 0) err(1, "reading from stdin"); } exit(0); } void printit(arg) const char *arg; { int ch, rot; if ((rot = atoi(arg)) < 0) errx(1, "bad rotation value."); while ((ch = getchar()) != EOF) putchar(ROTATE(ch, rot)); exit(0); } bsd-games-2.17/caesar/caesar.60000664000175000017500000000521307767741711014604 0ustar jsm28jsm28.\" $NetBSD: caesar.6,v 1.9 2003/08/07 09:37:07 agc Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)caesar.6 8.2 (Berkeley) 11/16/93 .\" .Dd November 16, 1993 .Dt CAESAR 6 .Os .Sh NAME .Nm caesar , .Nm rot13 .Nd decrypt caesar ciphers .Sh SYNOPSIS .Nm .Op Ar rotation .Sh DESCRIPTION The .Nm utility attempts to decrypt caesar ciphers using English letter frequency statistics. .Nm reads from the standard input and writes to the standard output. .Pp The optional numerical argument .Ar rotation may be used to specify a specific rotation value. .Pp The frequency (from most common to least) of English letters is as follows: .Pp .Bd -filled -offset indent ETAONRISHDLFCMUGPYWBVKXJQZ .Ed .Pp Their frequencies as a percentage are as follows: .Pp .Bd -filled -offset indent E(13), T(10.5), A(8.1), O(7.9), N(7.1), R(6.8), I(6.3), S(6.1), H(5.2), D(3.8), L(3.4), F(2.9), C(2.7), M(2.5), U(2.4), G(2), P(1.9), Y(1.9), W(1.5), B(1.4), V(.9), K(.4), X(.15), J(.13), Q(.11), Z(.07). .Ed .Pp Rotated postings to .Tn USENET and some of the databases used by the .Xr fortune 6 program are rotated by 13 characters. bsd-games-2.17/caesar/Makefrag0000664000175000017500000000352206773402557014716 0ustar jsm28jsm28# Makefrag - makefile fragment for caesar # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. caesar_DIRS := $(GAMESDIR) $(MAN6DIR) caesar_all: caesar/caesar caesar/caesar.6 caesar/rot13 caesar_install: caesar_all $(INSTALL_BINARY) caesar/caesar $(INSTALL_PREFIX)$(GAMESDIR)/caesar $(HIDE_GAME) caesar $(INSTALL_SCRIPT) caesar/rot13 $(INSTALL_PREFIX)$(GAMESDIR)/rot13 $(HIDE_GAME) rot13 $(INSTALL_MANUAL) caesar/caesar.6 $(INSTALL_MANUAL) caesar.6 rot13.6 bsd-games-2.17/caesar/rot13.in0000775000175000017500000000361107114231202014531 0ustar jsm28jsm28# $NetBSD: rot13.sh,v 1.6 2000/04/24 15:42:40 simonb Exp $ # # Copyright (c) 1992, 1993 # The Regents of the University of California. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by the University of # California, Berkeley and its contributors. # 4. Neither the name of the University nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # @(#)rot13.sh 8.1 (Berkeley) 5/31/93 # exec @gamesdir@/caesar 13 "$@" bsd-games-2.17/backgammon/0000775000175000017500000000000010205246605014076 5ustar jsm28jsm28bsd-games-2.17/backgammon/backgammon/0000775000175000017500000000000010205246605016175 5ustar jsm28jsm28bsd-games-2.17/backgammon/backgammon/backgammon.6.in0000664000175000017500000001154007767741711021012 0ustar jsm28jsm28.\" $NetBSD: backgammon.6,v 1.11 2003/08/07 09:36:55 agc Exp $ .\" .\" Copyright (c) 1980, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)backgammon.6 8.1 (Berkeley) 5/31/93 .\" .Dd May 31, 1993 .Dt BACKGAMMON 6 .Os .Sh NAME .Nm backgammon .Nd the game of backgammon .br .Nm teachgammon .Nd learn to play backgammon .Sh SYNOPSIS .Nm .Op Fl .Op Fl nrwb .Op Fl pr .Op Fl pw .Op Fl pb .Op Fl t Ar term .Op Fl s Ar file .br .Nm teachgammon .Sh DESCRIPTION This program lets you play backgammon against the computer or against a "friend". All commands are only one letter, so you don't need to type a carriage return, except at the end of a move. The program is mostly self-explanatory, so that a question mark (?) will usually get some help. If you answer `y' when the program asks if you want the rules, you will get text explaining the rules of the game, some hints on strategy, instructions on how to use the program, and a tutorial consisting of a practice game against the computer. A description of how to use the program can be obtained by answering `y' when it asks if you want instructions. .Pp The possible arguments for backgammon (most are unnecessary but some are very convenient) consist of: .Bl -tag -width indent .It Fl n don't ask for rules or instructions .It Fl r player is red (implies n) .It Fl w player is white (implies n) .It Fl b two players, red and white (implies n) .It Fl pr print the board before red's turn .It Fl pw print the board before white's turn .It Fl pb print the board before both player's turn .It Fl t Ar term terminal is type .Ar term , uses .Pa /usr/share/misc/termcap .It Fl s Ar file recover previously saved game from .Ar file .El .Pp .\" .\" Arguments may be optionally preceded by a `-'. .\" Several arguments may be concatenated together, .\" but not after `s' or `t' arguments, .\" since they can be followed by an arbitrary string. Any unrecognized arguments are ignored. An argument of a lone `-' gets a description of possible arguments. .Pp If .Ar term has capabilities for direct cursor movement (see .Xr termcap 5 ) .Nm ``fixes'' the board after each move, so the board does not need to be reprinted, unless the screen suffers some horrendous malady. Also, any `p' option will be ignored. (The `t' option is not necessary unless the terminal type does not match the entry in the .Pa /usr/share/misc/termcap data base.) .Sh QUICK REFERENCE When the program prompts by typing only your color, type a space or carriage return to roll, or .Bl -tag -width indent .It Ic d to double .It Ic p to print the board .It Ic q to quit .It Ic s to save the game for later .El .Pp When the program prompts with 'Move:', type .Bl -tag -width indent .It Ic p to print the board .It Ic q to quit .It Ic s to save the game .El .Pp or a .Em move , which is a sequence of .Bl -tag -width indent .It Ic s-f move from .Ic s to .Ic f .It Ic s/r move one man on .Ic s the roll .Ic r separated by commas or spaces and ending with a newline. Available abbreviations are .Bl -tag -width indent .It Ic s-f1-f2 means .Ic s-f1,f1-f2 .It Ic s/r1r2 means .Ic s/r1,s/r2 .El .El .Pp Use .Ic b for bar and .Ic h for home, or 0 or 25 as appropriate. .Sh AUTHOR .An Alan Char .Sh FILES .Bl -tag -width /usr/share/misc/termcap -compact .It Pa @gamesdir@/teachgammon rules and tutorial .It Pa /usr/share/misc/termcap terminal capabilities .El .Sh BUGS The program's strategy needs much work. bsd-games-2.17/backgammon/backgammon/backlocal.h0000664000175000017500000000423310005547567020274 0ustar jsm28jsm28/* $NetBSD: backlocal.h,v 1.2 2004/01/27 20:30:28 jsm Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ void dble(void); int dblgood(void); int eval(void); int freemen(int); void movcmp(void); void move(int); int movegood(void); void pickmove(void); int trapped(int, int); void trymove(int, int); bsd-games-2.17/backgammon/backgammon/Makefile.bsd0000664000175000017500000000031106450436434020407 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.9 1997/10/10 08:59:34 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= backgammon SRCS= extra.c main.c move.c text.c version.c MAN= backgammon.6 .include bsd-games-2.17/backgammon/backgammon/extra.c0000664000175000017500000001364307767741711017514 0ustar jsm28jsm28/* $NetBSD: extra.c,v 1.5 2003/08/07 09:36:55 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)extra.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: extra.c,v 1.5 2003/08/07 09:36:55 agc Exp $"); #endif #endif /* not lint */ #include "back.h" #include "backlocal.h" #ifdef DEBUG FILE *trace; #endif /* * dble() * Have the current player double and ask opponent to accept. */ void dble() { int resp; /* response to y/n */ for (;;) { writel(" doubles."); /* indicate double */ if (cturn == -pnum) { /* see if computer accepts */ if (dblgood()) { /* guess not */ writel(" Declined.\n"); nexturn(); cturn *= -2; /* indicate loss */ return; } else {/* computer accepts */ writel(" Accepted.\n"); gvalue *= 2; /* double game value */ dlast = cturn; if (tflag) gwrite(); return; } } /* ask if player accepts */ writel(" Does "); writel(cturn == 1 ? color[2] : color[3]); writel(" accept?"); /* get response from yorn, a "2" means he said "p" for print * board. */ if ((resp = yorn('R')) == 2) { writel(" Reprint.\n"); buflush(); wrboard(); writel(*Colorptr); continue; } /* check response */ if (resp) { /* accepted */ gvalue *= 2; dlast = cturn; if (tflag) gwrite(); return; } nexturn(); /* declined */ cturn *= -2; return; } } /* * dblgood () * Returns 1 if the computer would double in this position. This * is not an exact science. The computer will decline a double that he * would have made. Accumulated judgments are kept in the variable n, * which is in "pips", i.e., the position of each man summed over all * men, with opponent's totals negative. Thus, n should have a positive * value of 7 for each move ahead, or a negative value of 7 for each one * behind. */ int dblgood() { int n; /* accumulated judgment */ int OFFC = *offptr; /* no. of computer's men off */ int OFFO = *offopp; /* no. of player's men off */ #ifdef DEBUG int i; if (trace == NULL) trace = fopen("bgtrace", "w"); #endif /* get real pip value */ n = eval() * cturn; #ifdef DEBUG fputs("\nDoubles:\nBoard: ", trace); for (i = 0; i < 26; i++) fprintf(trace, " %d", board[i]); fprintf(trace, "\n\tpip = %d, ", n); #endif /* below adjusts pip value according to position judgments */ /* check men moving off board */ if (OFFC > -15 || OFFO > -15) { if (OFFC < 0 && OFFO < 0) { OFFC += 15; OFFO += 15; n += ((OFFC - OFFO) * 7) / 2; } else if (OFFC < 0) { OFFC += 15; n -= OFFO * 7 / 2; } else if (OFFO < 0) { OFFO += 15; n += OFFC * 7 / 2; } if (OFFC < 8 && OFFO > 8) n -= 7; if (OFFC < 10 && OFFO > 10) n -= 7; if (OFFC < 12 && OFFO > 12) n -= 7; if (OFFO < 8 && OFFC > 8) n += 7; if (OFFO < 10 && OFFC > 10) n += 7; if (OFFO < 12 && OFFC > 12) n += 7; n += ((OFFC - OFFO) * 7) / 2; } #ifdef DEBUG fprintf(trace, "off = %d, ", n); #endif /* see if men are trapped */ n -= freemen(bar); n += freemen(home); n += trapped(home, -cturn); n -= trapped(bar, cturn); #ifdef DEBUG fprintf(trace, "free = %d\n", n); fprintf(trace, "\tOFFC = %d, OFFO = %d\n", OFFC, OFFO); fflush(trace); #endif /* double if 2-3 moves ahead */ if (n > 10 + rnum(7)) return (1); return (0); } int freemen(b) int b; { int i, inc, lim; odds(0, 0, 0); if (board[b] == 0) return (0); inc = (b == 0 ? 1 : -1); lim = (b == 0 ? 7 : 18); for (i = b + inc; i != lim; i += inc) if (board[i] * inc < -1) odds(abs(b - i), 0, abs(board[b])); if (abs(board[b]) == 1) return ((36 - count()) / 5); return (count() / 5); } int trapped(n, inc) int n, inc; { int i, j, k; int c, l, ct; ct = 0; l = n + 7 * inc; for (i = n + inc; i != l; i += inc) { odds(0, 0, 0); c = abs(i - l); if (board[i] * inc > 0) { for (j = c; j < 13; j++) if (board[i + inc * j] * inc < -1) { if (j < 7) odds(j, 0, 1); for (k = 1; k < 7 && k < j; k++) if (j - k < 7) odds(k, j - k, 1); } ct += abs(board[i]) * (36 - count()); } } return (ct / 5); } int eval() { int i, j; for (j = i = 0; i < 26; i++) j += (board[i] >= 0 ? i * board[i] : (25 - i) * board[i]); if (off[1] >= 0) j += 25 * off[1]; else j += 25 * (off[1] + 15); if (off[0] >= 0) j -= 25 * off[0]; else j -= 25 * (off[0] + 15); return (j); } bsd-games-2.17/backgammon/backgammon/main.c0000664000175000017500000002712410204563462017275 0ustar jsm28jsm28/* $NetBSD: main.c,v 1.21 2005/02/15 12:56:20 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: main.c,v 1.21 2005/02/15 12:56:20 jsm Exp $"); #endif #endif /* not lint */ #include #include "back.h" #include "backlocal.h" #define MVPAUSE 5 /* time to sleep when stuck */ extern const char *const instr[]; /* text of instructions */ extern const char *const message[]; /* update message */ #ifndef NCURSES_VERSION short ospeed; /* tty output speed */ #endif const char *const helpm[] = { /* help message */ "Enter a space or newline to roll, or", " R to reprint the board\tD to double", " S to save the game\tQ to quit", 0 }; const char *const contin[] = { /* pause message */ "(Type a newline to continue.)", "", 0 }; static const char rules[] = "\nDo you want the rules of the game?"; static const char noteach[] = "Teachgammon not available!\n\a"; static const char need[] = "Do you need instructions for this program?"; static const char askcol[] = "Enter 'r' to play red, 'w' to play white, 'b' to play both:"; static const char rollr[] = "Red rolls a "; static const char rollw[] = ". White rolls a "; static const char rstart[] = ". Red starts.\n"; static const char wstart[] = ". White starts.\n"; static const char toobad1[] = "Too bad, "; static const char unable[] = " is unable to use that roll.\n"; static const char toobad2[] = ". Too bad, "; static const char cantmv[] = " can't move.\n"; static const char bgammon[] = "Backgammon! "; static const char gammon[] = "Gammon! "; static const char again[] = ".\nWould you like to play again?"; static const char svpromt[] = "Would you like to save this game?"; static const char password[] = "losfurng"; static char pbuf[10]; int main(argc, argv) int argc __attribute__((__unused__)); char **argv; { int i; /* non-descript index */ int l; /* non-descript index */ char c; /* non-descript character storage */ long t; /* time for random num generator */ /* revoke setgid privileges */ setregid(getgid(), getgid()); /* initialization */ bflag = 2; /* default no board */ signal(SIGINT, getout); /* trap interrupts */ if (tcgetattr(0, &old) == -1) /* get old tty mode */ errexit("backgammon(gtty)"); noech = old; noech.c_lflag &= ~ECHO; bg_raw = noech; bg_raw.c_lflag &= ~ICANON; /* set up modes */ ospeed = cfgetospeed(&old); /* for termlib */ /* get terminal capabilities, and decide if it can cursor address */ tflag = getcaps(getenv("TERM")); /* use whole screen for text */ if (tflag) begscr = 0; t = time(NULL); srandom(t); /* 'random' seed */ #ifdef V7 while (*++argv != 0) /* process arguments */ #else while (*++argv != -1) /* process arguments */ #endif getarg(&argv); args[acnt] = '\0'; if (tflag) { /* clear screen */ noech.c_oflag &= ~(ONLCR | OXTABS); bg_raw.c_oflag &= ~(ONLCR | OXTABS); clear(); } fixtty(&bg_raw); /* go into raw mode */ /* check if restored game and save flag for later */ if ((rfl = rflag) != 0) { text(message); /* print message */ text(contin); wrboard(); /* print board */ /* if new game, pretend to be a non-restored game */ if (cturn == 0) rflag = 0; } else { rscore = wscore = 0; /* zero score */ text(message); /* update message without pausing */ if (aflag) { /* print rules */ writel(rules); if (yorn(0)) { fixtty(&old); /* restore tty */ execl(TEACH, "teachgammon", args[1]?args:0, (char *) 0); tflag = 0; /* error! */ writel(noteach); exit(1); } else {/* if not rules, then instructions */ writel(need); if (yorn(0)) { /* print instructions */ clear(); text(instr); } } } init(); /* initialize board */ if (pnum == 2) {/* ask for color(s) */ writec('\n'); writel(askcol); while (pnum == 2) { c = readc(); switch (c) { case 'R': /* red */ pnum = -1; break; case 'W': /* white */ pnum = 1; break; case 'B': /* both */ pnum = 0; break; case 'P': if (iroll) break; if (tflag) curmove(curr, 0); else writec('\n'); writel("Password:"); signal(SIGALRM, getout); cflag = 1; alarm(10); for (i = 0; i < 10; i++) { pbuf[i] = readc(); if (pbuf[i] == '\n') break; } if (i == 10) while (readc() != '\n'); alarm(0); cflag = 0; if (i < 10) pbuf[i] = '\0'; for (i = 0; i < 9; i++) if (pbuf[i] != password[i]) getout(0); iroll = 1; if (tflag) curmove(curr, 0); else writec('\n'); writel(askcol); break; default: /* error */ writec('\007'); } } } else if (!aflag) /* pause to read message */ text(contin); wrboard(); /* print board */ if (tflag) curmove(18, 0); else writec('\n'); } /* limit text to bottom of screen */ if (tflag) begscr = 17; for (;;) { /* begin game! */ /* initial roll if needed */ if ((!rflag) || raflag) roll(); /* perform ritual of first roll */ if (!rflag) { if (tflag) curmove(17, 0); while (D0 == D1) /* no doubles */ roll(); /* print rolls */ writel(rollr); writec(D0 + '0'); writel(rollw); writec(D1 + '0'); /* winner goes first */ if (D0 > D1) { writel(rstart); cturn = 1; } else { writel(wstart); cturn = -1; } } /* initialize variables according to whose turn it is */ if (cturn == 1) { /* red */ home = 25; bar = 0; inptr = &in[1]; inopp = &in[0]; offptr = &off[1]; offopp = &off[0]; Colorptr = &color[1]; colorptr = &color[3]; colen = 3; } else { /* white */ home = 0; bar = 25; inptr = &in[0]; inopp = &in[1]; offptr = &off[0]; offopp = &off[1]; Colorptr = &color[0]; colorptr = &color[2]; colen = 5; } /* do first move (special case) */ if (!(rflag && raflag)) { if (cturn == pnum) /* computer's move */ move(0); else { /* player's move */ mvlim = movallow(); /* reprint roll */ if (tflag) curmove(cturn == -1 ? 18 : 19, 0); proll(); getmove(); /* get player's move */ } } if (tflag) { curmove(17, 0); cline(); begscr = 18; } /* no longer any diff- erence between normal game and * recovered game. */ rflag = 0; /* move as long as it's someone's turn */ while (cturn == 1 || cturn == -1) { /* board maintainence */ if (tflag) refresh(); /* fix board */ else /* redo board if -p */ if (cturn == bflag || bflag == 0) wrboard(); /* do computer's move */ if (cturn == pnum) { move(1); /* see if double refused */ if (cturn == -2 || cturn == 2) break; /* check for winning move */ if (*offopp == 15) { cturn *= -2; break; } continue; } /* (player's move) */ /* clean screen if safe */ if (tflag && hflag) { curmove(20, 0); clend(); hflag = 1; } /* if allowed, give him a chance to double */ if (dlast != cturn && gvalue < 64) { if (tflag) curmove(cturn == -1 ? 18 : 19, 0); writel(*Colorptr); c = readc(); /* character cases */ switch (c) { /* reprint board */ case 'R': wrboard(); break; /* save game */ case 'S': raflag = 1; save(1); break; /* quit */ case 'Q': quit(); break; /* double */ case 'D': dble(); break; /* roll */ case ' ': case '\n': roll(); writel(" rolls "); writec(D0 + '0'); writec(' '); writec(D1 + '0'); writel(". "); /* see if he can move */ if ((mvlim = movallow()) == 0) { /* can't move */ writel(toobad1); writel(*colorptr); writel(unable); if (tflag) { if (pnum) { buflush(); sleep(MVPAUSE); } } nexturn(); break; } /* get move */ getmove(); /* okay to clean screen */ hflag = 1; break; /* invalid character */ default: /* print help message */ if (tflag) curmove(20, 0); else writec('\n'); text(helpm); if (tflag) curmove(cturn == -1 ? 18 : 19, 0); else writec('\n'); /* don't erase */ hflag = 0; } } else {/* couldn't double */ /* print roll */ roll(); if (tflag) curmove(cturn == -1 ? 18 : 19, 0); proll(); /* can he move? */ if ((mvlim = movallow()) == 0) { /* he can't */ writel(toobad2); writel(*colorptr); writel(cantmv); buflush(); sleep(MVPAUSE); nexturn(); continue; } /* get move */ getmove(); } } /* don't worry about who won if quit */ if (cturn == 0) break; /* fix cturn = winner */ cturn /= -2; /* final board pos. */ if (tflag) refresh(); /* backgammon? */ mflag = 0; l = bar + 7 * cturn; for (i = bar; i != l; i += cturn) if (board[i] * cturn) mflag++; /* compute game value */ if (tflag) curmove(20, 0); if (*offopp == 15 && (*offptr == 0 || *offptr == -15)) { if (mflag) { writel(bgammon); gvalue *= 3; } else { writel(gammon); gvalue *= 2; } } /* report situation */ if (cturn == -1) { writel("Red wins "); rscore += gvalue; } else { writel("White wins "); wscore += gvalue; } wrint(gvalue); writel(" point"); if (gvalue > 1) writec('s'); writel(".\n"); /* write score */ wrscore(); /* see if he wants another game */ writel(again); if ((i = yorn('S')) == 0) break; init(); if (i == 2) { writel(" Save.\n"); cturn = 0; save(0); } /* yes, reset game */ wrboard(); } /* give him a chance to save if game was recovered */ if (rfl && cturn) { writel(svpromt); if (yorn(0)) { /* re-initialize for recovery */ init(); cturn = 0; save(0); } } /* leave peacefully */ getout(0); /* NOTREACHED */ return (0); } bsd-games-2.17/backgammon/backgammon/text.c0000664000175000017500000001441407767741711017352 0ustar jsm28jsm28/* $NetBSD: text.c,v 1.7 2003/08/07 09:36:56 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)text.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: text.c,v 1.7 2003/08/07 09:36:56 agc Exp $"); #endif #endif /* not lint */ #include "back.h" const char *const instr[] = { " If you did not notice by now, this program reacts to things as", "soon as you type them, without waiting for a newline. This means that", "the special characters RUBOUT, ESC, and CONTROL-D, will not perform", "their special functions during most of this program. The program", "should usually stop when a RUBOUT is typed, but occasionally it will", "ignore RUBOUTs until it is waiting for input.\n", " These instructions are presented in small chunks designed not to", "roll off the top of your screen. When the characters '-->' are print-", "ed, no more data will be printed until a space or newline is typed.", "In this way, you can finish one section before continuing to another.", "Like this:", "", " The two sides are colored 'red' and 'white.' The computer may play", "one side, or if there are two players, the computer can merely act as", "a gamekeeper, letting the players make the moves. Once you tell the", "computer what color(s) you want to play, the decision remains in ef-", "fect until you quit the program, even if you play more than one game,", "since the program keeps a running score.\n", " The program will prompt for a move in one of two ways. If the", "player has the opportunity to double, then merely his color will be", "typed out. The player can now do one of several things. He can dou-", "ble by typing a 'd', he can roll by typing a space (' ') or newline,", "or if he is not sure, he can reprint the board by typing a 'r'.\n", " If the player cannot double, his roll will be thrust in front of", "him, followed by the request 'Move:', asking for a move but not giving", "him the chance to double. He can still ask for the board by typing", "'r'. In either of these two states, the player can quit by typing 'q'", "or save the game by typing 's'. In either case, the player will be", "asked to verify, in case there was some error. The program then ends", "immediately, after first saving the file if so requested.", "", " A player can move one of his men using two forms of input. The", "first form is -, where is the starting position, and is", "the finishing position of the player's man. For example, if white", "wanted to move a piece from position 13 to position 8, his move could", "be entered as 13-8. The second form is / where is the", "starting position, an is the roll actually made. Hence, white", "could have entered as 13/5 instead of 13-8.\n", " A player must move each roll of the dice separately. For example,", "if a player rolled 4 3, and wanted to move from 13 to 6, he could", "enter it as 13/4,9/3 or 13/3,10/4 or 13-10,10-6 or 13-9,9-6, but not", "13-6. The last two entries can be shortened to 13-10-6 and 13-9-6.", "If you want to move more than one piece from the same position, such", "as 13-10,13-9, you can abbreviate this using the / format as by", "entering more than one , or 13/34. A player can use both forms for", "the same roll, e.g. 13/3,13-9, and separates individual moves by ei-", "ther a comma or a space. The letter 'b' represents the bar, and the", "letter 'h' represents a player's home. You could also enter the", "number that would be in the position of the bar, 25 or 0 as appropri-", "ate. Use a newline at the end of your moves for a turn.", "", " As you type in your move, if a character does not make sense under", "the above constrictions, a bell will sound instead of the character,", "and it will be ignored. You may kill lines and erase characters as", "you would normally, but don't be surprised if they look different than", "usual. Also, if you have entered one or more of your rolls, and you", "wish to see what the move looks like so far, type a 'r' to see what it", "looks like. This cannot be done in the middle of a move (e.g., after", "a '-' or '/'). After the printing board, the program will go back to", "inputting your move and you can backspace or kill just as if you had", "just typed in your input.\n", " Now you should be ready to begin the game. Good luck!", "", 0}; int text(t) const char *const *t; { int i; const char *s, *a; fixtty(&noech); while (*t != 0) { s = a = *t; for (i = 0; *a != '\0'; i--) a++; if (i) { writel(s); writec('\n'); } else { writel("-->"); fixtty(&bg_raw); while ((i = readc()) != ' ' && i != '\n'); fixtty(&noech); clear(); } t++; } fixtty(&bg_raw); return (0); } bsd-games-2.17/backgammon/backgammon/version.c0000664000175000017500000000364507767741711020057 0ustar jsm28jsm28/* $NetBSD: version.c,v 1.6 2003/08/07 09:36:56 agc Exp $ */ /* * Copyright (c) 1980, 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: version.c,v 1.6 2003/08/07 09:36:56 agc Exp $"); #endif #endif /* not lint */ const char *const message[] = { "Last updated on Friday, October 10, 1997.", 0 }; bsd-games-2.17/backgammon/backgammon/move.c0000664000175000017500000003011110005547567017314 0ustar jsm28jsm28/* $NetBSD: move.c,v 1.8 2004/01/27 20:30:28 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: move.c,v 1.8 2004/01/27 20:30:28 jsm Exp $"); #endif #endif /* not lint */ #include "back.h" #include "backlocal.h" #ifdef DEBUG FILE *trace; static char tests[20]; #endif struct BOARD { /* structure of game position */ int b_board[26]; /* board position */ int b_in[2]; /* men in */ int b_off[2]; /* men off */ int b_st[4], b_fn[4]; /* moves */ struct BOARD *b_next; /* forward queue pointer */ }; struct BOARD *freeq = 0; struct BOARD *checkq = 0; /* these variables are values for the candidate move */ static int ch; /* chance of being hit */ static int op; /* computer's open men */ static int pt; /* comp's protected points */ static int em; /* farthest man back */ static int frc; /* chance to free comp's men */ static int frp; /* chance to free pl's men */ /* these values are the values for the move chosen (so far) */ static int chance; /* chance of being hit */ static int openmen; /* computer's open men */ static int points; /* comp's protected points */ static int endman; /* farthest man back */ static int barmen; /* men on bar */ static int menin; /* men in inner table */ static int menoff; /* men off board */ static int oldfrc; /* chance to free comp's men */ static int oldfrp; /* chance to free pl's men */ static int cp[5]; /* candidate start position */ static int cg[5]; /* candidate finish position */ static int race; /* game reduced to a race */ static int bcomp(struct BOARD *, struct BOARD *); static struct BOARD *bsave(void); static void binsert(struct BOARD *); static void boardcopy(struct BOARD *); static void makefree(struct BOARD *); static void mvcheck(struct BOARD *, struct BOARD *); static struct BOARD *nextfree(void); void move(okay) int okay; /* zero if first move */ { int i; /* index */ int l; /* last man */ l = 0; if (okay) { /* see if comp should double */ if (gvalue < 64 && dlast != cturn && dblgood()) { writel(*Colorptr); dble(); /* double */ /* return if declined */ if (cturn != 1 && cturn != -1) return; } roll(); } race = 0; for (i = 0; i < 26; i++) { if (board[i] < 0) l = i; } for (i = 0; i < l; i++) { if (board[i] > 0) break; } if (i == l) race = 1; /* print roll */ if (tflag) curmove(cturn == -1 ? 18 : 19, 0); writel(*Colorptr); writel(" rolls "); writec(D0 + '0'); writec(' '); writec(D1 + '0'); /* make tty interruptable while thinking */ if (tflag) cline(); fixtty(&noech); /* find out how many moves */ mvlim = movallow(); if (mvlim == 0) { writel(" but cannot use it.\n"); nexturn(); fixtty(&bg_raw); return; } /* initialize */ for (i = 0; i < 4; i++) cp[i] = cg[i] = 0; /* strategize */ trymove(0, 0); pickmove(); /* print move */ writel(" and moves "); for (i = 0; i < mvlim; i++) { if (i > 0) writec(','); wrint(p[i] = cp[i]); writec('-'); wrint(g[i] = cg[i]); makmove(i); } writec('.'); /* print blots hit */ if (tflag) curmove(20, 0); else writec('\n'); for (i = 0; i < mvlim; i++) if (h[i]) wrhit(g[i]); /* get ready for next move */ nexturn(); if (!okay) { buflush(); sleep(3); } fixtty(&bg_raw); /* no more tty interrupt */ } void trymove(mvnum, swapped) int mvnum; /* number of move (rel zero) */ int swapped; /* see if swapped also tested */ { int pos; /* position on board */ int rval; /* value of roll */ /* if recursed through all dice values, compare move */ if (mvnum == mvlim) { binsert(bsave()); return; } /* make sure dice in always same order */ if (d0 == swapped) swap; /* choose value for this move */ rval = dice[mvnum != 0]; /* find all legitimate moves */ for (pos = bar; pos != home; pos += cturn) { /* fix order of dice */ if (d0 == swapped) swap; /* break if stuck on bar */ if (board[bar] != 0 && pos != bar) break; /* on to next if not occupied */ if (board[pos] * cturn <= 0) continue; /* set up arrays for move */ p[mvnum] = pos; g[mvnum] = pos + rval * cturn; if (g[mvnum] * cturn >= home) { if (*offptr < 0) break; g[mvnum] = home; } /* try to move */ if (makmove(mvnum)) continue; else trymove(mvnum + 1, 2); /* undo move to try another */ backone(mvnum); } /* swap dice and try again */ if ((!swapped) && D0 != D1) trymove(0, 1); } static struct BOARD * bsave() { int i; /* index */ struct BOARD *now; /* current position */ now = nextfree(); /* get free BOARD */ /* store position */ for (i = 0; i < 26; i++) now->b_board[i] = board[i]; now->b_in[0] = in[0]; now->b_in[1] = in[1]; now->b_off[0] = off[0]; now->b_off[1] = off[1]; for (i = 0; i < mvlim; i++) { now->b_st[i] = p[i]; now->b_fn[i] = g[i]; } return (now); } static void binsert(new) struct BOARD *new; /* item to insert */ { struct BOARD *p = checkq; /* queue pointer */ int result; /* comparison result */ if (p == 0) { /* check if queue empty */ checkq = p = new; p->b_next = 0; return; } result = bcomp(new, p); /* compare to first element */ if (result < 0) { /* insert in front */ new->b_next = p; checkq = new; return; } if (result == 0) { /* duplicate entry */ mvcheck(p, new); makefree(new); return; } while (p->b_next != 0) {/* traverse queue */ result = bcomp(new, p->b_next); if (result < 0) { /* found place */ new->b_next = p->b_next; p->b_next = new; return; } if (result == 0) { /* duplicate entry */ mvcheck(p->b_next, new); makefree(new); return; } p = p->b_next; } /* place at end of queue */ p->b_next = new; new->b_next = 0; } static int bcomp(a, b) struct BOARD *a; struct BOARD *b; { int *aloc = a->b_board; /* pointer to board a */ int *bloc = b->b_board; /* pointer to board b */ int i; /* index */ int result; /* comparison result */ for (i = 0; i < 26; i++) { /* compare boards */ result = cturn * (aloc[i] - bloc[i]); if (result) return (result); /* found inequality */ } return (0); /* same position */ } static void mvcheck(incumbent, candidate) struct BOARD *incumbent; struct BOARD *candidate; { int i; int result; for (i = 0; i < mvlim; i++) { result = cturn * (candidate->b_st[i] - incumbent->b_st[i]); if (result > 0) return; if (result < 0) break; } if (i == mvlim) return; for (i = 0; i < mvlim; i++) { incumbent->b_st[i] = candidate->b_st[i]; incumbent->b_fn[i] = candidate->b_fn[i]; } } void makefree(dead) struct BOARD *dead; /* dead position */ { dead->b_next = freeq; /* add to freeq */ freeq = dead; } static struct BOARD * nextfree() { struct BOARD *new; if (freeq == 0) { new = (struct BOARD *) calloc(1, sizeof(struct BOARD)); if (new == 0) { writel("\nOut of memory\n"); getout(0); } } else { new = freeq; freeq = freeq->b_next; } new->b_next = 0; return (new); } void pickmove() { /* current game position */ struct BOARD *now = bsave(); struct BOARD *next; /* next move */ #ifdef DEBUG if (trace == NULL) trace = fopen("bgtrace", "w"); fprintf(trace, "\nRoll: %d %d%s\n", D0, D1, race ? " (race)" : ""); fflush(trace); #endif do { /* compare moves */ boardcopy(checkq); next = checkq->b_next; makefree(checkq); checkq = next; movcmp(); } while (checkq != 0); boardcopy(now); } static void boardcopy(s) struct BOARD *s; /* game situation */ { int i; /* index */ for (i = 0; i < 26; i++) board[i] = s->b_board[i]; for (i = 0; i < 2; i++) { in[i] = s->b_in[i]; off[i] = s->b_off[i]; } for (i = 0; i < mvlim; i++) { p[i] = s->b_st[i]; g[i] = s->b_fn[i]; } } void movcmp() { int i; #ifdef DEBUG if (trace == NULL) trace = fopen("bgtrace", "w"); #endif odds(0, 0, 0); if (!race) { ch = op = pt = 0; for (i = 1; i < 25; i++) { if (board[i] == cturn) ch = canhit(i, 1); op += abs(bar - i); } for (i = bar + cturn; i != home; i += cturn) if (board[i] * cturn > 1) pt += abs(bar - i); frc = freemen(bar) + trapped(bar, cturn); frp = freemen(home) + trapped(home, -cturn); } for (em = bar; em != home; em += cturn) if (board[em] * cturn > 0) break; em = abs(home - em); #ifdef DEBUG fputs("Board: ", trace); for (i = 0; i < 26; i++) fprintf(trace, " %d", board[i]); if (race) fprintf(trace, "\n\tem = %d\n", em); else fprintf(trace, "\n\tch = %d, pt = %d, em = %d, frc = %d, frp = %d\n", ch, pt, em, frc, frp); fputs("\tMove: ", trace); for (i = 0; i < mvlim; i++) fprintf(trace, " %d-%d", p[i], g[i]); fputs("\n", trace); fflush(trace); strcpy(tests, ""); #endif if ((cp[0] == 0 && cg[0] == 0) || movegood()) { #ifdef DEBUG fprintf(trace, "\t[%s] ... wins.\n", tests); fflush(trace); #endif for (i = 0; i < mvlim; i++) { cp[i] = p[i]; cg[i] = g[i]; } if (!race) { chance = ch; openmen = op; points = pt; endman = em; barmen = abs(board[home]); oldfrc = frc; oldfrp = frp; } menin = *inptr; menoff = *offptr; } #ifdef DEBUG else { fprintf(trace, "\t[%s] ... loses.\n", tests); fflush(trace); } #endif } int movegood() { int n; if (*offptr == 15) return (1); if (menoff == 15) return (0); if (race) { #ifdef DEBUG strcat(tests, "o"); #endif if (*offptr - menoff) return (*offptr > menoff); #ifdef DEBUG strcat(tests, "e"); #endif if (endman - em) return (endman > em); #ifdef DEBUG strcat(tests, "i"); #endif if (menin == 15) return (0); if (*inptr == 15) return (1); #ifdef DEBUG strcat(tests, "i"); #endif if (*inptr - menin) return (*inptr > menin); return (rnum(2)); } else { n = barmen - abs(board[home]); #ifdef DEBUG strcat(tests, "c"); #endif if (abs(chance - ch) + 25 * n > rnum(150)) return (n ? (n < 0) : (ch < chance)); #ifdef DEBUG strcat(tests, "o"); #endif if (*offptr - menoff) return (*offptr > menoff); #ifdef DEBUG strcat(tests, "o"); #endif if (abs(openmen - op) > 7 + rnum(12)) return (openmen > op); #ifdef DEBUG strcat(tests, "b"); #endif if (n) return (n < 0); #ifdef DEBUG strcat(tests, "e"); #endif if (abs(endman - em) > rnum(2)) return (endman > em); #ifdef DEBUG strcat(tests, "f"); #endif if (abs(frc - oldfrc) > rnum(2)) return (frc < oldfrc); #ifdef DEBUG strcat(tests, "p"); #endif if (abs(n = pt - points) > rnum(4)) return (n > 0); #ifdef DEBUG strcat(tests, "i"); #endif if (*inptr - menin) return (*inptr > menin); #ifdef DEBUG strcat(tests, "f"); #endif if (abs(frp - oldfrp) > rnum(2)) return (frp > oldfrp); return (rnum(2)); } } bsd-games-2.17/backgammon/backgammon/Makefrag0000664000175000017500000000367706773402557017671 0ustar jsm28jsm28# Makefile - makefile fragment for backgammon/backgammon # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. backgammon_backgammon_DEFS := -DV7 backgammon_backgammon_DIRS := $(GAMESDIR) $(MAN6DIR) backgammon_backgammon_INCS := -Ibackgammon/common_source backgammon_backgammon_all: backgammon/backgammon/backgammon backgammon/backgammon/backgammon.6 backgammon_backgammon_install: backgammon_backgammon_all $(INSTALL_BINARY) backgammon/backgammon/backgammon $(INSTALL_PREFIX)$(GAMESDIR)/backgammon $(HIDE_GAME) backgammon $(INSTALL_MANUAL) backgammon/backgammon/backgammon.6 bsd-games-2.17/backgammon/teachgammon/0000775000175000017500000000000010205246605016361 5ustar jsm28jsm28bsd-games-2.17/backgammon/teachgammon/Makefile.bsd0000664000175000017500000000032007641024615020570 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.11 2002/09/18 06:16:39 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 NOMAN= # defined PROG= teachgammon SRCS= data.c teach.c ttext1.c ttext2.c tutor.c .include bsd-games-2.17/backgammon/teachgammon/tutor.h0000664000175000017500000000477710005547567017737 0ustar jsm28jsm28/* $NetBSD: tutor.h,v 1.8 2004/01/27 20:30:28 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)tutor.h 8.1 (Berkeley) 5/31/93 */ struct situatn { int brd[26]; int roll1; int roll2; int mp[4]; int mg[4]; int new1; int new2; const char *const (*com[8]); }; extern const char *const doubl[]; extern const char *const endgame[]; extern const char *const finis[]; extern const char *const hello[]; extern const char *const hits[]; extern const char *const intro1[]; extern const char *const intro2[]; extern const char *const lastch[]; extern const char *const list[]; extern int maxmoves; extern const char *const moves[]; extern const char *const opts; extern const char *const prog[]; extern const char *const prompt; extern const char *const removepiece[]; extern const char *const stragy[]; extern const struct situatn test[]; int brdeq(const int *, const int *); void clrest(void); void leave(void) __attribute__((__noreturn__)); void tutor(void) __attribute__((__noreturn__)); bsd-games-2.17/backgammon/teachgammon/teach.c0000664000175000017500000000737210204563462017624 0ustar jsm28jsm28/* $NetBSD: teach.c,v 1.16 2005/02/15 12:56:20 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: teach.c,v 1.16 2005/02/15 12:56:20 jsm Exp $"); #endif #endif /* not lint */ #include "back.h" #include "tutor.h" const char *const helpm[] = { "\nEnter a space or newline to roll, or", " b to display the board", " d to double", " q to quit\n", 0 }; const char *const contin[] = { "", 0 }; int main(argc, argv) int argc __attribute__((__unused__)); char *argv[]; { int i; /* revoke setgid privileges */ setregid(getgid(), getgid()); signal(SIGINT, getout); if (tcgetattr(0, &old) == -1) /* get old tty mode */ errexit("teachgammon(gtty)"); noech = old; noech.c_lflag &= ~ECHO; bg_raw = noech; bg_raw.c_lflag &= ~ICANON; /* set up modes */ ospeed = cfgetospeed(&old); /* for termlib */ tflag = getcaps(getenv("TERM")); #ifdef V7 while (*++argv != 0) #else while (*++argv != -1) #endif getarg(&argv); if (tflag) { noech.c_oflag &= ~(ONLCR | OXTABS); bg_raw.c_oflag &= ~(ONLCR | OXTABS); clear(); } text(hello); text(list); i = text(contin); if (i == 0) i = 2; init(); while (i) switch (i) { case 1: leave(); case 2: if ((i = text(intro1)) != 0) break; wrboard(); if ((i = text(intro2)) != 0) break; case 3: if ((i = text(moves)) != 0) break; case 4: if ((i = text(removepiece)) != 0) break; case 5: if ((i = text(hits)) != 0) break; case 6: if ((i = text(endgame)) != 0) break; case 7: if ((i = text(doubl)) != 0) break; case 8: if ((i = text(stragy)) != 0) break; case 9: if ((i = text(prog)) != 0) break; case 10: if ((i = text(lastch)) != 0) break; } tutor(); /* NOTREACHED */ return (0); } void leave() { if (tflag) clear(); else writec('\n'); fixtty(&old); execl(EXEC, "backgammon", "-n", args[1]?args:0, (char *) 0); writel("Help! Backgammon program is missing\007!!\n"); exit(1); } bsd-games-2.17/backgammon/teachgammon/data.c0000664000175000017500000002563107775331303017455 0ustar jsm28jsm28/* $NetBSD: data.c,v 1.7 2004/01/01 15:59:09 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: data.c,v 1.7 2004/01/01 15:59:09 jsm Exp $"); #endif #endif /* not lint */ #include "tutor.h" int maxmoves = 23; const char *const text0[] = { "To start the game, I roll a 3, and you roll a 1. This means", "that I get to start first. I move 8-5,6-5 since this makes a", "new point and helps to trap your back men on 1. You should be", "able to do a similar move with your roll.", 0 }; const char *const text1[] = { "Now you shall see a move using doubles. I just rolled double", "5's. I will move two men from position 13 to position 3. The", "notation for this is 13-8,13-8,8-3,8-3. You will also roll dou-", "bles, but you will be able to make a much stronger move.", 0 }; const char *const text2[] = { "Excellent! As you can see, you are beginning to develop a wall", "which is trapping my men on position 24. Also, moving your back", "men forward not only improves your board position safely, but it", "thwarts my effort to make a wall.", "", "My roll now is 5 6. Normally, I would use that roll to move from", "position 24 to position 13 (24-18-13), but your new point prevents", "that. Instead, I am forced to move from 13 to 2, where my man is", "open but cannot be hit.", 0 }; const char *const text3[] = { "As you can see, although you left a man open, it is a rela-", "tively safe move to an advantageous position, which might help", "you make a point later. Only two rolls (4 5 or 5 4) will allow", "me to hit you. With an unprecedented amount of luck, I happen", "to roll a 4 5 and hit you as just mentioned.", 0 }; const char *const text4[] = { "You're pretty lucky yourself, you know. I follow by rolling 2 3", "and moving 25-22,24-22, forming a new point.", 0 }; const char *const text5[] = { "Not a spectacular move, but a safe one. I follow by rolling 6 1.", "I decide to use this roll to move 22-16,16-15. It leaves me with", "one man still open, but the blot is farther back on the board, and", "would suffer less of a loss by being hit.", 0 }; const char *const text6[] = { "By moving your two men from 17 to 20, you lessen my chance of", "getting my man off the board. In fact, the odds are 5 to 4", "against me getting off. I roll with the odds and helplessly", "receive a 3 5.", 0 }; const char *const text7[] = { "Note that the blot on 7 cannot be hit unless I get off the bar", "and have a 1 or a 6 left over, and doing so will leave two of", "my men open. Also, the blot on 16 cannot be hit at all! With", "a sigh of frustration, I roll double 6's and remain immobile.", 0 }; const char *const text8[] = { "See, you did not get hit and, you got to 'cover up' your open men.", "Quite an accomplishment. Finally, I get off the bar by rolling", "6 2 and moving 25-23,23-17.", 0 }; const char *const text9[] = { "My venture off the bar did not last long. However, I got lucky", "and rolled double 1's, allowing me to move 25-24,24-23,15-14,15-14.", 0 }; const char *const text10[] = { "You are improving your position greatly and safely, and are well", "on the way to winning the game. I roll a 6 2 and squeak past", "your back man. Now the game becomes a race to the finish.", 0 }; const char *const text11[] = { "Now that it is merely a race, you are trying to get as many men", "as possible into the inner table, so you can start removing them.", "I roll a 3 4 and move my two men farthest back to position 11", "(15-11,14-11).", 0 }; const char *const text12[] = { "The race is still on, and you have seem to be doing all right.", "I roll 6 1 and move 14-8,13-12.", 0 }; const char *const text13[] = { "Notice that you get to remove men the instant you have all of", "them at your inner table, even if it is the middle of a turn.", "I roll 1 2 and move 13-11,12-11.", 0 }; const char *const text14[] = { "Although you could have removed a man, this move illustrates two", "points: 1) You never have to remove men, and 2) You should try", "to spread out your men on your inner table. Since you have one", "man on each position, you should be able to remove at least two", "men next turn. I roll 2 5 and move 8-6,11-6.", 0 }; const char *const text15[] = { "This time you were able to remove men. I roll 3 4 and move", "11-7,11-8. The race continues.", 0 }; const char *const text16[] = { "More holes are opening up in your inner table, but you are", "still very much ahead. If we were doubling, you would have", "doubled long ago. I roll 2 6 and move 8-6,11-5.", 0 }; const char *const text17[] = { "It pays to spread out your men. I roll 3 5 and move 7-4,8-3.", 0 }; const char *const text18[] = { "You can only remove some men, but you spread out more and", "more, in order to be able to remove men more efficiently.", "I roll double 3's, which help, but not that much. I move", "8-5,3-0,3-0,3-0.", 0 }; const char *const text19[] = { "I roll 1 4 and move 5-4,4-0.", 0 }; const char *const text20[] = { "You are now nicely spread out to win a game. I roll 5 6 and", "move 5-0,6-0.", 0 }; const char *const text21[] = { "Any minute now. Just a few short steps from victory. I roll", "2 4 and move 6-4,4-0.", 0 }; const char *const text22[] = { "It looks pretty hopeless for me, but I play on, rolling 1 3 and", "moving 4-3,3-0.", 0 }; const char *const text23[] = { "Congratulations! You just won a game of backgammon against the", "computer! You will now be able to play a game, but remember,", "when you start playing, that doubling will be enabled, which", "will add another factor to the game... Good luck!!", "", 0 }; const struct situatn test[] = { { {0, 2, 0, 0, 0, 0, -5, 0, -3, 0, 0, 0, 5, -5, 0, 0, 0, 3, 0, 5, 0, 0, 0, 0, -2, 0}, 3, 1, {8, 6, 0, 0}, {5, 5, 0, 0}, 4, 2, {text0} }, { {0, 2, 0, 0, 0, -2, -4, 0, -2, 0, 0, 0, 5, -5, 0, 0, 0, 2, 0, 4, 0, 2, 0, 0, -2, 0}, 5, 5, {13, 13, 8, 8}, {8, 8, 3, 3}, 6, 6, {text1} }, { {0, 0, 0, -2, 0, -2, -4, 2, -2, 0, 0, 0, 3, -3, 0, 0, 0, 2, 2, 4, 0, 2, 0, 0, -2, 0}, 6, 5, {13, 8, 0, 0}, {8, 2, 0, 0}, 1, 2, {text2} }, { {0, 0, -1, -2, 0, -2, -4, 2, -2, 0, 0, 0, 2, -2, 0, 1, 0, 2, 2, 4, 0, 2, 0, 0, -2, 0}, 4, 5, {24, 20, 0, 0}, {20, 15, 0, 0}, 2, 5, {text3} }, { {0, 0, 0, -2, 0, -2, -4, 3, -2, 0, 0, 0, 2, -2, 0, -1, 0, 2, 2, 4, 0, 2, 0, 0, -1, -1}, 2, 3, {25, 24, 0, 0}, {22, 22, 0, 0}, 4, 1, {text4} }, { {0, 0, 0, -2, 0, -2, -4, 2, -2, 0, 0, 0, 3, -2, 0, -1, 0, 2, 2, 4, 0, 2, -2, 0, 0, 0}, 6, 1, {22, 16, 0, 0}, {16, 15, 0, 0}, 3, 3, {text5} }, { {0, 0, 0, -2, 0, -2, -4, 2, -2, 0, 0, 0, 3, -2, 0, -2, 0, 0, 2, 2, 2, 2, 2, 0, 0, -1}, 3, 5, {0, 0, 0, 0}, {0, 0, 0, 0}, 5, 4, {text6} }, { {0, 0, 0, -2, 0, -2, -4, 1, -2, 0, 0, 0, 3, -2, 0, -2, 1, 0, 2, 2, 2, 2, 2, 0, 0, -1}, 6, 6, {0, 0, 0, 0}, {0, 0, 0, 0}, 3, 6, {text7} }, { {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, 0, 3, -2, 0, -2, 2, 0, 2, 2, 2, 2, 2, 0, 0, -1}, 2, 6, {25, 23, 0, 0}, {23, 17, 0, 0}, 5, 1, {text8} }, { {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, 0, 2, -2, 0, -2, 2, 0, 3, 2, 2, 2, 2, 0, 0, -1}, 1, 1, {25, 24, 15, 15}, {24, 23, 14, 14}, 4, 6, {text9} }, { {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, 0, 0, -2, -2, 0, 3, 0, 4, 2, 2, 2, 2, -1, 0, 0}, 6, 2, {23, 17, 0, 0}, {17, 15, 0, 0}, 1, 3, {text10} }, { {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, 0, 0, -2, -2, -1, 2, 0, 3, 4, 2, 2, 2, 0, 0, 0}, 4, 3, {15, 14, 0, 0}, {11, 11, 0, 0}, 5, 3, {text11} }, { {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, -2, 0, -2, -1, 0, 0, 0, 3, 5, 2, 3, 2, 0, 0, 0}, 6, 1, {14, 13, 0, 0}, {8, 12, 0, 0}, 4, 4, {text12} }, { {0, 0, 0, -2, 0, -2, -4, 0, -3, 0, 0, -2, -1, -1, 0, 0, 0, 0, 0, 5, 2, 2, 5, 0, 0, 0}, 2, 1, {13, 12, 0, 0}, {11, 11, 0, 0}, 2, 1, {text13} }, { {0, 0, 0, -2, 0, -2, -4, 0, -3, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 5, 2, 2, 3, 1, 1, 0}, 2, 5, {8, 11, 0, 0}, {6, 6, 0, 0}, 6, 3, {text14} }, { {0, 0, 0, -2, 0, -2, -6, 0, -2, 0, 0, -3, 0, 0, 0, 0, 0, 0, 0, 4, 2, 2, 2, 1, 1, 0}, 4, 3, {11, 11, 0, 0}, {7, 8, 0, 0}, 2, 5, {text15} }, { {0, 0, 0, -2, 0, -2, -6, -1, -3, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 4, 1, 2, 2, 0, 1, 0}, 2, 6, {8, 11, 0, 0}, {6, 5, 0, 0}, 6, 1, {text16} }, { {0, 0, 0, -2, 0, -3, -7, -1, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 2, 2, 0, 0, 0}, 5, 3, {8, 7, 0, 0}, {3, 4, 0, 0}, 5, 2, {text17} }, { {0, 0, 0, -3, -1, -3, -7, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 2, 1, 0, 0}, 3, 3, {8, 3, 3, 3}, {5, 0, 0, 0}, 1, 6, {text18} }, { {0, 0, 0, 0, -1, -4, -7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 0, 0}, 1, 4, {4, 5, 0, 0}, {0, 4, 0, 0}, 2, 3, {text19} }, { {0, 0, 0, 0, -1, -3, -7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0}, 5, 6, {6, 5, 0, 0}, {0, 0, 0, 0}, 1, 4, {text20} }, { {0, 0, 0, 0, -1, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0}, 2, 4, {4, 6, 0, 0}, {0, 4, 0, 0}, 6, 2, {text21} }, { {0, 0, 0, 0, -1, -2, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0}, 3, 1, {4, 3, 0, 0}, {3, 0, 0, 0}, 4, 3, {text22} }, { {0, 0, 0, 0, 0, -2, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, {text23} } }; bsd-games-2.17/backgammon/teachgammon/ttext1.c0000664000175000017500000002105607767741711020003 0ustar jsm28jsm28/* $NetBSD: ttext1.c,v 1.7 2003/08/07 09:36:58 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: ttext1.c,v 1.7 2003/08/07 09:36:58 agc Exp $"); #endif #endif /* not lint */ #include "back.h" #include "tutor.h" const char *const opts = " QIMRHEDSPT"; const char *const prompt = "-->"; const char *const list[] = { "\n\n\tI\tIntroduction to Backgammon", "\tM\tMoves and Points", "\tR\tRemoving Men from the Board", "\tH\tHitting Blots", "\tE\tEnding the Game and Scoring", "\tD\tDoubling", "\tS\tStrategy", "\tP\tThe Program and How to Use It", "\nalso, you can type:", "\t?\tto get this list", "\tQ\tto go start playing", "\tT\tto go straight to the tutorial", 0 }; const char *const hello[] = { "\n These rules consist of text describing how to play Backgammon", "followed by a tutorial session where you play a practice game", "against the computer. When using this program, think carefuly", "before typing, since it reacts as soon as you type something. In", "addition, the program presents text output, such as these rules,", "in small blocks that will not roll off the top of the screen.", "Frequently, you will see the characters '-->' indicating that the", "program is waiting for you to finish reading, and will continue", "printing when you type a space or newline. Also, the rules are", "divided into sections, and although you should read them in or-", "der, you can go directly to any of them by typing one of the fol-", "lowing letters:", "(Remember to hit a space or a newline to continue.)", "", 0 }; const char *const intro1[] = { "\nIntroduction:", "\n Backgammon is a game involving the skill of two players and", "the luck of two dice. There are two players, red and white, and", "each player gets fifteen men. The object of the game is to re-", "move all your men from the board before the opponent does. The", "board consists of twenty-four positions, a 'bar' and a 'home' for", "each player. It looks like this:", "", 0}; const char *const intro2[] = { "", "\n Although not indicated on the board, the players' homes are", "located just to the right of the board. A player's men are placed", "there when they are removed from the board. The board you just", "saw was in it's initial position. All games start with the board", "looking like this. Notice that red's pieces are represented by the", "letter 'r' and white's pieces are represented by the letter 'w'.", "Also, a position may have zero or more pieces on it, e.g. posi-", "tion 12 has five red pieces on it, while position 11 does not", "have any pieces of either color.", "", 0}; const char *const moves[] = { "\nMoves and Points:", "\n Moves are made along the positions on the board according to", "their numbers. Red moves in the positive direction (clockwise", "from 1 to 24), and white moves in the negative direction (coun-", "terclockwise from 24 to 1).", "\n A turn consists of rolling the dice, and moving the number of", "positions indicated on each die. The two numbers can be used to", "move one man the sum of the two rolls, or two men the number on", "each individual die. For example, if red rolled 6 3 at the start", "of the game, he might move a man from 1 to 7 to 10, using both", "dice for one man, or he might move two men from position 12, one", "to 15 and one to 18. (Red did not have to choose two men start-", "ing from the same position.) In addition, doubles are treated", "specially in backgammon. When a player rolls doubles, he gets to", "move as if he had four dice instead of two. For instance, if you", "rolled double 2's, you could move one man eight positions, four", "men two positions each, or any permutation in between.", "", "\n However, there are certain limitations, called 'points.' A", "player has a point when he has two or more men on the same posi-", "tion. This gives him custody of that position, and his opponent", "cannot place his men there, even if passing through on the way to", "another position. When a player has six points in a row, it is", "called a 'wall,' since any of his opponent's men behind the wall", "cannot pass it and are trapped, at least for the moment. Notice", "that this could mean that a player could not use part or all of", "his roll. However, he must use as much of his roll as possible.", "", 0}; const char *const removepiece[] = { "\nRemoving Men from the Board:", "\n The most important part of the game is removing men, since", "that is how you win the game. Once a man is removed, he stays", "off the board for the duration of the game. However, a player", "cannot remove men until all his men are on his 'inner table,' or", "the last six positions of the board (19-24 for red, 6-1 for", "white).", "\n To get off the board, a player must roll the exact number to", "get his man one position past the last position on the board, or", "his 'home.' Hence, if red wanted to remove a man from position", "23, he would have to roll a 2, anything else would be used for", "another man, or for another purpose. However, there is one ex-", "ception. If the player rolling has no men far enough to move the", "roll made, he may move his farthest man off the board. For exam-", "ple, if red's farthest man back was on position 21, he could re-", "move men from that position if he rolled a 5 or a 6, as well as a", "4. Since he does not have men on 20 (where he could use a 5) or", "on 19 (where he could use a 6), he can use these rolls for posi-", "tion 21. A player never has to remove men, but he must make as", "many moves as possible.", "", 0}; const char *const hits[] = { "\nHitting Blots:", "\n Although two men on a position form an impenetrable point, a", "lone man is not so secure. Such a man is called a 'blot' and has", "the potential of getting hit by an opposing man. When a player's", "blot is hit, he is placed on the bar, and the first thing that", "player must do is move the man off the bar. Such moves are", "counted as if the bar is one position behind the first position", "on the board. Thus if red has a man on the bar and rolls 2 3, he", "must move the man on the bar to position 2 or 3 before moving any", "other man. If white had points on positions 2 and 3, then red", "would forfeit his turn. Being on the bar is a very bad position,", "for often a player can lose many turns trying to move off the", "bar, as well as being set back the full distance of the board.", "", 0}; const char *const endgame[] = { "\nEnding the Game and Scoring:", "\n Winning a game usually wins one point, the normal value of a", "game. However, if the losing player has not removed any men yet,", "then the winning player wins double the game value, called a", "'gammon.' If the losing player has a player on the bar or on the", "winner's inner table, then the winner gets triple the game value,", "which is called a 'backgammon.' (So that's where the name comes", "from!)", "", 0}; bsd-games-2.17/backgammon/teachgammon/ttext2.c0000664000175000017500000001613007767741711020001 0ustar jsm28jsm28/* $NetBSD: ttext2.c,v 1.7 2003/08/07 09:36:58 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: ttext2.c,v 1.7 2003/08/07 09:36:58 agc Exp $"); #endif #endif /* not lint */ #include "back.h" #include "tutor.h" const char *const doubl[] = { "\nDoubling:", "\n If a player thinks he is in a good position, he may double the", "value of the game. However, his opponent may not accept the pro-", "posal and forfeit the game before the price gets too high. A", "player must double before he rolls, and once his double has been", "accepted, he cannot double again, until his opponent has doubled.", "Thus, unless the game swings back and forth in advantage between", "the two players a great deal, the value of the game should be", "low. At any rate, the value of the game will never go above 64,", "or six doubles. However, if a player wins a backgammon at 64", "points, he wins 192 points!", "", 0}; const char *const stragy[] = { "\nStrategy:", "\n Some general hints when playing: Try not to leave men open", "unless absolutely necessary. Also, it is good to make as many", "points as possible. Often, two men from different positions can", "be brought together to form a new point. Although walls (six", "points in a row) are difficult to form, many points nestled close-", "ly together produce a formidable barrier. Also, while it is good", "to move back men forward, doing so lessens the opportunity for you", "to hit men. Finally, remember that once the two player's have", "passed each other on the board, there is no chance of either team", "being hit, so the game reduces to a race off the board. Addi-", "tional hints on strategy are presented in the practice game.", "", 0}; const char *const prog[] = { "\nThe Program and How It Works:", "\n A general rule of thumb is when you don't know what to do,", "type a question mark, and you should get some help. When it is", "your turn, only your color will be printed out, with nothing", "after it. You may double by typing a 'd', but if you type a", "space or newline, you will get your roll. (Remember, you must", "double before you roll.) Also, typing a 'r' will reprint the", "board, and a 'q' will quit the game. The program will type", "'Move:' when it wants your move, and you may indicate each die's", "move with -, where is the starting position and is", "the finishing position, or / where is the roll made.", "-- is short for -,- and / is", "short for /,/. Moves may be separated by a comma", "or a space.", "", "\n While typing, any input which does not make sense will not be", "echoed, and a bell will sound instead. Also, backspacing and", "killing lines will echo differently than normal. You may examine", "the board by typing a 'r' if you have made a partial move, or be-", "fore you type a newline, to see what the board looks like. You", "must end your move with a newline. If you cannot double, your", "roll will always be printed, and you will not be given the oppor-", "tunity to double. Home and bar are represented by the appropri-", "ate number, 0 or 25 as the case may be, or by the letters 'h' or", "'b' as appropriate. You may also type 'r' or 'q' when the program", "types 'Move:', which has the same effect as above. Finally, you", "will get to decide if you want to play red or white (or both if you", "want to play a friend) at the beginning of the session, and you", "will not get to change your mind later, since the computer keeps", "score.", "", 0}; const char *const lastch[] = { "\nTutorial (Practice Game):", "\n This tutorial, for simplicity's sake, will let you play one", "predetermined game. All the rolls have been pre-arranged, and", "only one response will let you advance to the next move.", "Although a given roll will may have several legal moves, the tu-", "torial will only accept one (not including the same moves in a", "different order), claiming that that move is 'best.' Obviously,", "a subjective statement. At any rate, be patient with it and have", "fun learning about backgammon. Also, to speed things up a lit-", "tle, doubling will not take place in the tutorial, so you will", "never get that opportunity, and quitting only leaves the tutori-", "al, not the game. You will still be able to play backgammon", "after quitting.", "\n This is your last chance to look over the rules before the tu-", "torial starts.", "", 0}; int text(txt) const char *const *txt; { const char *const *begin; const char *a; char b; const char *c; int i; fixtty(&noech); begin = txt; while (*txt) { a = *(txt++); if (*a != '\0') { c = a; for (i = 0; *(c++) != '\0'; i--); writel(a); writec('\n'); } else { fixtty(&bg_raw); writel(prompt); for (;;) { if ((b = readc()) == '?') { if (tflag) { if (begscr) { curmove(18, 0); clend(); } else clear(); } else writec('\n'); text(list); writel(prompt); continue; } i = 0; if (b == '\n') break; while (i < 11) { if (b == opts[i]) break; i++; } if (i == 11) writec('\007'); else break; } if (tflag) { if (begscr) { curmove(18, 0); clend(); } else clear(); } else writec('\n'); if (i) return (i); fixtty(&noech); if (tflag) curmove(curr, 0); begin = txt; } } fixtty(&bg_raw); return (0); } bsd-games-2.17/backgammon/teachgammon/Makefrag0000664000175000017500000000364106773402557020044 0ustar jsm28jsm28# Makefrag - makefile fragment for backgammon/teachgammon # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. backgammon_teachgammon_DEFS := -DV7 backgammon_teachgammon_DIRS := $(GAMESDIR) $(MAN6DIR) backgammon_teachgammon_INCS := -Ibackgammon/common_source backgammon_teachgammon_all: backgammon/teachgammon/teachgammon backgammon_teachgammon_install: backgammon_teachgammon_all $(INSTALL_BINARY) backgammon/teachgammon/teachgammon $(INSTALL_PREFIX)$(GAMESDIR)/teachgammon $(HIDE_GAME) teachgammon $(INSTALL_MANUAL) backgammon.6 teachgammon.6 bsd-games-2.17/backgammon/teachgammon/tutor.c0000664000175000017500000000700707767741711017727 0ustar jsm28jsm28/* $NetBSD: tutor.c,v 1.6 2003/08/07 09:36:58 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: tutor.c,v 1.6 2003/08/07 09:36:58 agc Exp $"); #endif #endif /* not lint */ #include "back.h" #include "tutor.h" static const char better[] = "That is a legal move, but there is a better one.\n"; void tutor() { int i, j; i = 0; begscr = 18; cturn = -1; home = 0; bar = 25; inptr = &in[0]; inopp = &in[1]; offptr = &off[0]; offopp = &off[1]; Colorptr = &color[0]; colorptr = &color[2]; colen = 5; wrboard(); while (1) { if (!brdeq(test[i].brd, board)) { if (tflag && curr == 23) curmove(18, 0); writel(better); nexturn(); movback(mvlim); if (tflag) { refresh(); clrest(); } if ((!tflag) || curr == 19) { proll(); writec('\t'); } else curmove(curr > 19 ? curr - 2 : curr + 4, 25); getmove(); if (cturn == 0) leave(); continue; } if (tflag) curmove(18, 0); text(*test[i].com); if (!tflag) writec('\n'); if (i == maxmoves) break; D0 = test[i].roll1; D1 = test[i].roll2; d0 = 0; mvlim = 0; for (j = 0; j < 4; j++) { if (test[i].mp[j] == test[i].mg[j]) break; p[j] = test[i].mp[j]; g[j] = test[i].mg[j]; mvlim++; } if (mvlim) for (j = 0; j < mvlim; j++) if (makmove(j)) writel("AARGH!!!\n"); if (tflag) refresh(); nexturn(); D0 = test[i].new1; D1 = test[i].new2; d0 = 0; i++; mvlim = movallow(); if (mvlim) { if (tflag) clrest(); proll(); writec('\t'); getmove(); if (tflag) refresh(); if (cturn == 0) leave(); } } leave(); } void clrest() { int r, c, j; r = curr; c = curc; for (j = r + 1; j < 24; j++) { curmove(j, 0); cline(); } curmove(r, c); } int brdeq(b1, b2) const int *b1, *b2; { const int *e; e = b1 + 26; while (b1 < e) if (*b1++ != *b2++) return (0); return (1); } bsd-games-2.17/backgammon/common_source/0000775000175000017500000000000010205246605016746 5ustar jsm28jsm28bsd-games-2.17/backgammon/common_source/Makefile.bsd0000664000175000017500000000040407641024615021160 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.7 2002/09/18 06:16:39 lukem Exp $ NOLINKLIB= # defined NOLINT= # defined NOPIC= # defined NOPROFILE= # defined LIB= common SRCS= allow.c board.c check.c fancy.c init.c odds.c \ one.c save.c subs.c table.c .include bsd-games-2.17/backgammon/common_source/allow.c0000664000175000017500000000571007767741711020254 0ustar jsm28jsm28/* $NetBSD: allow.c,v 1.5 2003/08/07 09:36:56 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)allow.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: allow.c,v 1.5 2003/08/07 09:36:56 agc Exp $"); #endif #endif /* not lint */ #include "back.h" int movallow() { int i, m, iold; int r; if (d0) swap; m = (D0 == D1 ? 4 : 2); for (i = 0; i < 4; i++) p[i] = bar; i = iold = 0; while (i < m) { if (*offptr == 15) break; h[i] = 0; if (board[bar]) { if (i == 1 || m == 4) g[i] = bar + cturn * D1; else g[i] = bar + cturn * D0; if ((r = makmove(i)) != 0) { if (d0 || m == 4) break; swap; movback(i); if (i > iold) iold = i; for (i = 0; i < 4; i++) p[i] = bar; i = 0; } else i++; continue; } if ((p[i] += cturn) == home) { if (i > iold) iold = i; if (m == 2 && i) { movback(i); p[i--] = bar; if (p[i] != bar) continue; else break; } if (d0 || m == 4) break; swap; movback(i); for (i = 0; i < 4; i++) p[i] = bar; i = 0; continue; } if (i == 1 || m == 4) g[i] = p[i] + cturn * D1; else g[i] = p[i] + cturn * D0; if (g[i] * cturn > home) { if (*offptr >= 0) g[i] = home; else continue; } if (board[p[i]] * cturn > 0 && (r = makmove(i)) == 0) i++; } movback(i); return (iold > i ? iold : i); } bsd-games-2.17/backgammon/common_source/save.c0000664000175000017500000001114307767741711020071 0ustar jsm28jsm28/* $NetBSD: save.c,v 1.10 2003/08/07 09:36:57 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: save.c,v 1.10 2003/08/07 09:36:57 agc Exp $"); #endif #endif /* not lint */ #include #include "back.h" static const char confirm[] = "Are you sure you want to leave now?"; static const char prompt[] = "Enter a file name: "; static const char exist1[] = "The file '"; static const char exist2[] = "' already exists.\nAre you sure you want to use this file?"; static const char cantuse[] = "\nCan't use "; static const char saved[] = "This game has been saved on the file '"; static const char type[] = "'.\nType \"backgammon "; static const char rec[] = "\" to recover your game.\n\n"; static const char cantrec[] = "Can't recover file: "; void save(n) int n; { int fdesc; char *fs; char fname[50]; if (n) { if (tflag) { curmove(20, 0); clend(); } else writec('\n'); writel(confirm); if (!yorn(0)) return; } cflag = 1; for (;;) { writel(prompt); fs = fname; while ((*fs = readc()) != '\n') { if (*fs == old.c_cc[VERASE]) { if (fs > fname) { fs--; if (tflag) curmove(curr, curc - 1); else writec(*fs); } else writec('\007'); continue; } writec(*fs++); } *fs = '\0'; if ((fdesc = open(fname, O_RDWR)) == -1 && errno == ENOENT) { if ((fdesc = creat(fname, 0600)) != -1) break; } if (fdesc != -1) { if (tflag) { curmove(18, 0); clend(); } else writec('\n'); writel(exist1); writel(fname); writel(exist2); cflag = 0; close(fdesc); if (yorn(0)) { unlink(fname); fdesc = creat(fname, 0600); break; } else { cflag = 1; continue; } } writel(cantuse); writel(fname); writel(".\n"); close(fdesc); cflag = 1; } write(fdesc, board, sizeof board); write(fdesc, off, sizeof off); write(fdesc, in, sizeof in); write(fdesc, dice, sizeof dice); write(fdesc, &cturn, sizeof cturn); write(fdesc, &dlast, sizeof dlast); write(fdesc, &pnum, sizeof pnum); write(fdesc, &rscore, sizeof rscore); write(fdesc, &wscore, sizeof wscore); write(fdesc, &gvalue, sizeof gvalue); write(fdesc, &raflag, sizeof raflag); close(fdesc); if (tflag) curmove(18, 0); writel(saved); writel(fname); writel(type); writel(fname); writel(rec); if (tflag) clend(); getout(0); } void recover(s) const char *s; { int fdesc; if ((fdesc = open(s, O_RDONLY)) == -1) norec(s); read(fdesc, board, sizeof board); read(fdesc, off, sizeof off); read(fdesc, in, sizeof in); read(fdesc, dice, sizeof dice); read(fdesc, &cturn, sizeof cturn); read(fdesc, &dlast, sizeof dlast); read(fdesc, &pnum, sizeof pnum); read(fdesc, &rscore, sizeof rscore); read(fdesc, &wscore, sizeof wscore); read(fdesc, &gvalue, sizeof gvalue); read(fdesc, &raflag, sizeof raflag); close(fdesc); rflag = 1; } void norec(s) const char *s; { const char *c; tflag = 0; writel(cantrec); c = s; while (*c != '\0') writec(*c++); getout(0); } bsd-games-2.17/backgammon/common_source/fancy.c0000664000175000017500000004116110042511025020203 0ustar jsm28jsm28/* $NetBSD: fancy.c,v 1.12 2004/04/23 02:58:27 simonb Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)fancy.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: fancy.c,v 1.12 2004/04/23 02:58:27 simonb Exp $"); #endif #endif /* not lint */ #include "back.h" extern char PC; /* padding character */ extern char *BC; /* backspace sequence */ char *CD; /* clear to end of screen sequence */ char *CE; /* clear to end of line sequence */ char *CL; /* clear screen sequence */ char *CM; /* cursor movement instructions */ char *HO; /* home cursor sequence */ char *MC; /* column cursor movement map */ char *ML; /* row cursor movement map */ char *ND; /* forward cursor sequence */ extern char *UP; /* up cursor sequence */ int lHO; /* length of HO */ int lBC; /* length of BC */ int lND; /* length of ND */ int lUP; /* length of UP */ int CO; /* number of columns */ int LI; /* number of lines */ int *linect; /* array of lengths of lines on screen (the * actual screen is not stored) */ /* two letter codes */ char tcap[] = "bccdceclcmhomcmlndup"; /* corresponding strings */ char **tstr[] = {&BC, &CD, &CE, &CL, &CM, &HO, &MC, &ML, &ND, &UP}; extern int buffnum; /* pointer to output buffer */ char tbuf[1024]; /* buffer for decoded termcap entries */ int oldb[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int oldr; int oldw; /* "real" cursor positions, so it knows when to reposition. These are -1 if * curr and curc are accurate */ int realr; int realc; void fboard() { int i, j, l; curmove(0, 0); /* do top line */ for (i = 0; i < 53; i++) fancyc('_'); curmove(15, 0); /* do botttom line */ for (i = 0; i < 53; i++) fancyc('_'); l = 1; /* do vertical lines */ for (i = 52; i > -1; i -= 28) { curmove((l == 1 ? 1 : 15), i); fancyc('|'); for (j = 0; j < 14; j++) { curmove(curr + l, curc - 1); fancyc('|'); } if (i == 24) i += 32; l = -l; /* alternate directions */ } curmove(2, 1); /* label positions 13-18 */ for (i = 13; i < 18; i++) { fancyc('1'); fancyc((i % 10) + '0'); curmove(curr, curc + 2); } fancyc('1'); fancyc('8'); curmove(2, 29); /* label positions 19-24 */ fancyc('1'); fancyc('9'); for (i = 20; i < 25; i++) { curmove(curr, curc + 2); fancyc('2'); fancyc((i % 10) + '0'); } curmove(14, 1); /* label positions 12-7 */ fancyc('1'); fancyc('2'); for (i = 11; i > 6; i--) { curmove(curr, curc + 2); fancyc(i > 9 ? '1' : ' '); fancyc((i % 10) + '0'); } curmove(14, 30); /* label positions 6-1 */ fancyc('6'); for (i = 5; i > 0; i--) { curmove(curr, curc + 3); fancyc(i + '0'); } for (i = 12; i > 6; i--)/* print positions 12-7 */ if (board[i]) bsect(board[i], 13, 1 + 4 * (12 - i), -1); if (board[0]) /* print red men on bar */ bsect(board[0], 13, 25, -1); for (i = 6; i > 0; i--) /* print positions 6-1 */ if (board[i]) bsect(board[i], 13, 29 + 4 * (6 - i), -1); l = (off[1] < 0 ? off[1] + 15 : off[1]); /* print white's home */ bsect(l, 3, 54, 1); curmove(8, 25); /* print the word BAR */ fancyc('B'); fancyc('A'); fancyc('R'); for (i = 13; i < 19; i++) /* print positions 13-18 */ if (board[i]) bsect(board[i], 3, 1 + 4 * (i - 13), 1); if (board[25]) /* print white's men on bar */ bsect(board[25], 3, 25, 1); for (i = 19; i < 25; i++) /* print positions 19-24 */ if (board[i]) bsect(board[i], 3, 29 + 4 * (i - 19), 1); l = (off[0] < 0 ? off[0] + 15 : off[0]); /* print red's home */ bsect(-l, 13, 54, -1); for (i = 0; i < 26; i++)/* save board position for refresh later */ oldb[i] = board[i]; oldr = (off[1] < 0 ? off[1] + 15 : off[1]); oldw = -(off[0] < 0 ? off[0] + 15 : off[0]); } /* * bsect (b,rpos,cpos,cnext) * Print the contents of a board position. "b" has the value of the * position, "rpos" is the row to start printing, "cpos" is the column to * start printing, and "cnext" is positive if the position starts at the top * and negative if it starts at the bottom. The value of "cpos" is checked * to see if the position is a player's home, since those are printed * differently. */ void bsect(b, rpos, cpos, cnext) int b; /* contents of position */ int rpos; /* row of position */ int cpos; /* column of position */ int cnext; /* direction of position */ { int j; /* index */ int n; /* number of men on position */ int bct; /* counter */ int k; /* index */ char pc; /* color of men on position */ bct = 0; n = abs(b); /* initialize n and pc */ pc = (b > 0 ? 'r' : 'w'); if (n < 6 && cpos < 54) /* position cursor at start */ curmove(rpos, cpos + 1); else curmove(rpos, cpos); for (j = 0; j < 5; j++) { /* print position row by row */ for (k = 0; k < 15; k += 5) /* print men */ if (n > j + k) fancyc(pc); if (j < 4) { /* figure how far to back up for next row */ if (n < 6) { /* stop if none left */ if (j + 1 == n) break; bct = 1; /* single column */ } else { if (n < 11) { /* two columns */ if (cpos == 54) { /* home pos */ if (j + 5 >= n) bct = 1; else bct = 2; } if (cpos < 54) { /* not home */ if (j + 6 >= n) bct = 1; else bct = 2; } } else { /* three columns */ if (j + 10 >= n) bct = 2; else bct = 3; } } curmove(curr + cnext, curc - bct); /* reposition cursor */ } } } void refresh() { int i, r, c; r = curr; /* save current position */ c = curc; for (i = 12; i > 6; i--)/* fix positions 12-7 */ if (board[i] != oldb[i]) { fixpos(oldb[i], board[i], 13, 1 + (12 - i) * 4, -1); oldb[i] = board[i]; } if (board[0] != oldb[0]) { /* fix red men on bar */ fixpos(oldb[0], board[0], 13, 25, -1); oldb[0] = board[0]; } for (i = 6; i > 0; i--) /* fix positions 6-1 */ if (board[i] != oldb[i]) { fixpos(oldb[i], board[i], 13, 29 + (6 - i) * 4, -1); oldb[i] = board[i]; } i = -(off[0] < 0 ? off[0] + 15 : off[0]); /* fix white's home */ if (oldw != i) { fixpos(oldw, i, 13, 54, -1); oldw = i; } for (i = 13; i < 19; i++) /* fix positions 13-18 */ if (board[i] != oldb[i]) { fixpos(oldb[i], board[i], 3, 1 + (i - 13) * 4, 1); oldb[i] = board[i]; } if (board[25] != oldb[25]) { /* fix white men on bar */ fixpos(oldb[25], board[25], 3, 25, 1); oldb[25] = board[25]; } for (i = 19; i < 25; i++) /* fix positions 19-24 */ if (board[i] != oldb[i]) { fixpos(oldb[i], board[i], 3, 29 + (i - 19) * 4, 1); oldb[i] = board[i]; } i = (off[1] < 0 ? off[1] + 15 : off[1]); /* fix red's home */ if (oldr != i) { fixpos(oldr, i, 3, 54, 1); oldr = i; } curmove(r, c); /* return to saved position */ newpos(); buflush(); } void fixpos(old, new, r, c, inc) int old, new, r, c, inc; { int o, n, nv; int ov, nc; char col; nc = 0; if (old * new >= 0) { ov = abs(old); nv = abs(new); col = (old + new > 0 ? 'r' : 'w'); o = (ov - 1) / 5; n = (nv - 1) / 5; if (o == n) { if (o == 2) nc = c + 2; if (o == 1) nc = c < 54 ? c : c + 1; if (o == 0) nc = c < 54 ? c + 1 : c; if (ov > nv) fixcol(r + inc * (nv - n * 5), nc, abs(ov - nv), ' ', inc); else fixcol(r + inc * (ov - o * 5), nc, abs(ov - nv), col, inc); return; } else { if (c < 54) { if (o + n == 1) { if (n) { fixcol(r, c, abs(nv - 5), col, inc); if (ov != 5) fixcol(r + inc * ov, c + 1, abs(ov - 5), col, inc); } else { fixcol(r, c, abs(ov - 5), ' ', inc); if (nv != 5) fixcol(r + inc * nv, c + 1, abs(nv - 5), ' ', inc); } return; } if (n == 2) { if (ov != 10) fixcol(r + inc * (ov - 5), c, abs(ov - 10), col, inc); fixcol(r, c + 2, abs(nv - 10), col, inc); } else { if (nv != 10) fixcol(r + inc * (nv - 5), c, abs(nv - 10), ' ', inc); fixcol(r, c + 2, abs(ov - 10), ' ', inc); } return; } if (n > o) { fixcol(r + inc * (ov % 5), c + o, abs(5 * n - ov), col, inc); if (nv != 5 * n) fixcol(r, c + n, abs(5 * n - nv), col, inc); } else { fixcol(r + inc * (nv % 5), c + n, abs(5 * n - nv), ' ', inc); if (ov != 5 * o) fixcol(r, c + o, abs(5 * o - ov), ' ', inc); } return; } } nv = abs(new); fixcol(r, c + 1, nv, new > 0 ? 'r' : 'w', inc); if (abs(old) <= abs(new)) return; fixcol(r + inc * new, c + 1, abs(old + new), ' ', inc); } void fixcol(r, c, l, ch, inc) int l, ch, r, c, inc; { int i; curmove(r, c); fancyc(ch); for (i = 1; i < l; i++) { curmove(curr + inc, curc - 1); fancyc(ch); } } void curmove(r, c) int r, c; { if (curr == r && curc == c) return; if (realr == -1) { realr = curr; realc = curc; } curr = r; curc = c; } void newpos() { int r; /* destination row */ int c; /* destination column */ int mode = -1; /* mode of movement */ int count = 1000; /* character count */ int i; /* index */ int n; /* temporary variable */ char *m; /* string containing CM movement */ m = NULL; if (realr == -1) /* see if already there */ return; r = curr; /* set current and dest. positions */ c = curc; curr = realr; curc = realc; /* double check position */ if (curr == r && curc == c) { realr = realc = -1; return; } if (CM) { /* try CM to get there */ mode = 0; m = (char *) tgoto(CM, c, r); count = strlen(m); } /* try HO and local movement */ if (HO && (n = r + c * lND + lHO) < count) { mode = 1; count = n; } /* try various LF combinations */ if (r >= curr) { /* CR, LF, and ND */ if ((n = (r - curr) + c * lND + 1) < count) { mode = 2; count = n; } /* LF, ND */ if (c >= curc && (n = (r - curr) + (c - curc) * lND) < count) { mode = 3; count = n; } /* LF, BS */ if (c < curc && (n = (r - curr) + (curc - c) * lBC) < count) { mode = 4; count = n; } } /* try corresponding UP combinations */ if (r < curr) { /* CR, UP, and ND */ if ((n = (curr - r) * lUP + c * lND + 1) < count) { mode = 5; count = n; } /* UP and ND */ if (c >= curc && (n = (curr - r) * lUP + (c - curc) * lND) < count) { mode = 6; count = n; } /* UP and BS */ if (c < curc && (n = (curr - r) * lUP + (curc - c) * lBC) < count) { mode = 7; count = n; } } /* space over */ if (curr == r && c > curc && linect[r] < curc && c - curc < count) mode = 8; switch (mode) { case -1: /* error! */ write(2, "\r\nInternal cursor error.\r\n", 26); getout(0); /* direct cursor motion */ case 0: tputs(m, abs(curr - r), addbuf); break; /* relative to "home" */ case 1: tputs(HO, r, addbuf); for (i = 0; i < r; i++) addbuf('\012'); for (i = 0; i < c; i++) tputs(ND, 1, addbuf); break; /* CR and down and over */ case 2: addbuf('\015'); for (i = 0; i < r - curr; i++) addbuf('\012'); for (i = 0; i < c; i++) tputs(ND, 1, addbuf); break; /* down and over */ case 3: for (i = 0; i < r - curr; i++) addbuf('\012'); for (i = 0; i < c - curc; i++) tputs(ND, 1, addbuf); break; /* down and back */ case 4: for (i = 0; i < r - curr; i++) addbuf('\012'); for (i = 0; i < curc - c; i++) addbuf('\010'); break; /* CR and up and over */ case 5: addbuf('\015'); for (i = 0; i < curr - r; i++) tputs(UP, 1, addbuf); for (i = 0; i < c; i++) tputs(ND, 1, addbuf); break; /* up and over */ case 6: for (i = 0; i < curr - r; i++) tputs(UP, 1, addbuf); for (i = 0; i < c - curc; i++) tputs(ND, 1, addbuf); break; /* up and back */ case 7: for (i = 0; i < curr - r; i++) tputs(UP, 1, addbuf); for (i = 0; i < curc - c; i++) { if (BC) tputs(BC, 1, addbuf); else addbuf('\010'); } break; /* safe space */ case 8: for (i = 0; i < c - curc; i++) addbuf(' '); } /* fix positions */ curr = r; curc = c; realr = -1; realc = -1; } void clear() { int i; /* double space if can't clear */ if (CL == 0) { writel("\n\n"); return; } curr = curc = 0; /* fix position markers */ realr = realc = -1; for (i = 0; i < 24; i++)/* clear line counts */ linect[i] = -1; buffnum = -1; /* ignore leftover buffer contents */ tputs(CL, CO, addbuf); /* put CL in buffer */ } void fancyc(c) char c; /* character to output */ { int sp; /* counts spaces in a tab */ if (c == '\007') { /* bells go in blindly */ addbuf(c); return; } /* process tabs, use spaces if the tab should be erasing things, * otherwise use cursor movement routines. Note this does not use * hardware tabs at all. */ if (c == '\t') { sp = (curc + 8) & (~7); /* compute spaces */ /* check line length */ if (linect[curr] >= curc || sp < 4) { for (; sp > curc; sp--) addbuf(' '); curc = sp; /* fix curc */ } else curmove(curr, sp); return; } /* do newline be calling newline */ if (c == '\n') { newline(); return; } /* ignore any other control chars */ if (c < ' ') return; /* if an erasing space or non-space, just add it to buffer. Otherwise * use cursor movement routine, so that multiple spaces will be * grouped together */ if (c > ' ' || linect[curr] >= curc) { newpos(); /* make sure position correct */ addbuf(c); /* add character to buffer */ /* fix line length */ if (c == ' ' && linect[curr] == curc) linect[curr]--; else if (linect[curr] < curc) linect[curr] = curc; curc++; /* fix curc */ } else /* use cursor movement routine */ curmove(curr, curc + 1); } void clend() { int i; if (CD) { tputs(CD, CO - curr, addbuf); for (i = curr; i < LI; i++) linect[i] = -1; return; } curmove(i = curr, 0); cline(); while (curr < LI - 1) { curmove(curr + 1, 0); if (linect[curr] > -1) cline(); } curmove(i, 0); } void cline() { int c; if (curc > linect[curr]) return; newpos(); if (CE) { tputs(CE, 1, addbuf); linect[curr] = curc - 1; } else { c = curc - 1; while (linect[curr] > c) { addbuf(' '); curc++; linect[curr]--; } curmove(curr, c + 1); } } void newline() { cline(); if (curr == LI - 1) curmove(begscr, 0); else curmove(curr + 1, 0); } int getcaps(s) const char *s; { char *code; /* two letter code */ char ***cap; /* pointer to cap string */ char *bufp; /* pointer to cap buffer */ char tentry[1024]; /* temporary uncoded caps buffer */ tgetent(tentry, s); /* get uncoded termcap entry */ LI = tgetnum("li"); /* get number of lines */ if (LI == -1) LI = 12; CO = tgetnum("co"); /* get number of columns */ if (CO == -1) CO = 65; bufp = tbuf; /* get padding character */ tgetstr("pc", &bufp); if (bufp != tbuf) PC = *tbuf; else PC = 0; bufp = tbuf; /* get string entries */ cap = tstr; for (code = tcap; *code; code += 2) **cap++ = (char *) tgetstr(code, &bufp); /* get pertinent lengths */ if (HO) lHO = strlen(HO); if (BC) lBC = strlen(BC); else lBC = 1; if (UP) lUP = strlen(UP); if (ND) lND = strlen(ND); if (LI < 24 || CO < 72 || !(CL && UP && ND)) return (0); linect = (int *) calloc(LI + 1, sizeof(int)); if (linect == NULL) { write(2, "\r\nOut of memory!\r\n", 18); getout(0); } return (1); } bsd-games-2.17/backgammon/common_source/one.c0000664000175000017500000000747607767741711017732 0ustar jsm28jsm28/* $NetBSD: one.c,v 1.5 2003/08/07 09:36:57 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)one.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: one.c,v 1.5 2003/08/07 09:36:57 agc Exp $"); #endif #endif /* not lint */ #include "back.h" int makmove(i) int i; { int n, d; int max; d = d0; n = abs(g[i] - p[i]); max = (*offptr < 0 ? 7 : last()); if (board[p[i]] * cturn <= 0) return (checkd(d) + 2); if (g[i] != home && board[g[i]] * cturn < -1) return (checkd(d) + 3); if (i || D0 == D1) { if (n == max ? D1 < n : D1 != n) return (checkd(d) + 1); } else { if (n == max ? D0 < n && D1 < n : D0 != n && D1 != n) return (checkd(d) + 1); if (n == max ? D0 < n : D0 != n) { if (d0) return (checkd(d) + 1); swap; } } if (g[i] == home && *offptr < 0) return (checkd(d) + 4); h[i] = 0; board[p[i]] -= cturn; if (g[i] != home) { if (board[g[i]] == -cturn) { board[home] -= cturn; board[g[i]] = 0; h[i] = 1; if (abs(bar - g[i]) < 7) { (*inopp)--; if (*offopp >= 0) *offopp -= 15; } } board[g[i]] += cturn; if (abs(home - g[i]) < 7 && abs(home - p[i]) > 6) { (*inptr)++; if (*inptr + *offptr == 0) *offptr += 15; } } else { (*offptr)++; (*inptr)--; } return (0); } void moverr(i) int i; { int j; if (tflag) curmove(20, 0); else writec('\n'); writel("Error: "); for (j = 0; j <= i; j++) { wrint(p[j]); writec('-'); wrint(g[j]); if (j < i) writec(','); } writel("... "); movback(i); } int checkd(d) int d; { if (d0 != d) swap; return (0); } int last() { int i; for (i = home - 6 * cturn; i != home; i += cturn) if (board[i] * cturn > 0) return (abs(home - i)); return (-1); } void movback(i) int i; { int j; for (j = i - 1; j >= 0; j--) backone(j); } void backone(i) int i; { board[p[i]] += cturn; if (g[i] != home) { board[g[i]] -= cturn; if (abs(g[i] - home) < 7 && abs(p[i] - home) > 6) { (*inptr)--; if (*inptr + *offptr < 15 && *offptr >= 0) *offptr -= 15; } } else { (*offptr)--; (*inptr)++; } if (h[i]) { board[home] += cturn; board[g[i]] = -cturn; if (abs(bar - g[i]) < 7) { (*inopp)++; if (*inopp + *offopp == 0) *offopp += 15; } } } bsd-games-2.17/backgammon/common_source/board.c0000664000175000017500000001042507767741711020224 0ustar jsm28jsm28/* $NetBSD: board.c,v 1.7 2003/08/07 09:36:57 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)board.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: board.c,v 1.7 2003/08/07 09:36:57 agc Exp $"); #endif #endif /* not lint */ #include "back.h" static int i, j, k; static char ln[60]; void wrboard() { int l; static const char bl[] = "| | | |\n"; static const char sv[] = "| | | | \n"; fixtty(&noech); clear(); if (tflag) { fboard(); goto lastline; } writel("_____________________________________________________\n"); writel(bl); strcpy(ln, bl); for (j = 1; j < 50; j += 4) { k = j / 4 + (j > 24 ? 12 : 13); ln[j + 1] = k % 10 + '0'; ln[j] = k / 10 + '0'; if (j == 21) j += 4; } writel(ln); for (i = 0; i < 5; i++) { strcpy(ln, sv); for (j = 1; j < 50; j += 4) { k = j / 4 + (j > 24 ? 12 : 13); wrbsub(); if (j == 21) j += 4; } if (-board[25] > i) ln[26] = 'w'; if (-board[25] > i + 5) ln[25] = 'w'; if (-board[25] > i + 10) ln[27] = 'w'; l = 53; if (off[1] > i || (off[1] < 0 && off[1] + 15 > i)) { ln[54] = 'r'; l = 55; } if (off[1] > i + 5 || (off[1] < 0 && off[1] + 15 > i + 5)) { ln[55] = 'r'; l = 56; } if (off[1] > i + 10 || (off[1] < 0 && off[1] + 15 > i + 10)) { ln[56] = 'r'; l = 57; } ln[l++] = '\n'; ln[l] = '\0'; writel(ln); } strcpy(ln, bl); ln[25] = 'B'; ln[26] = 'A'; ln[27] = 'R'; writel(ln); strcpy(ln, sv); for (i = 4; i > -1; i--) { for (j = 1; j < 50; j += 4) { k = ((j > 24 ? 53 : 49) - j) / 4; wrbsub(); if (j == 21) j += 4; } if (board[0] > i) ln[26] = 'r'; if (board[0] > i + 5) ln[25] = 'r'; if (board[0] > i + 10) ln[27] = 'r'; l = 53; if (off[0] > i || (off[0] < 0 && off[0] + 15 > i)) { ln[54] = 'w'; l = 55; } if (off[0] > i + 5 || (off[0] < 0 && off[0] + 15 > i + 5)) { ln[55] = 'w'; l = 56; } if (off[0] > i + 10 || (off[0] < 0 && off[0] + 15 > i + 10)) { ln[56] = 'w'; l = 57; } ln[l++] = '\n'; ln[l] = '\0'; writel(ln); } strcpy(ln, bl); for (j = 1; j < 50; j += 4) { k = ((j > 24 ? 53 : 49) - j) / 4; ln[j + 1] = k % 10 + '0'; if (k > 9) ln[j] = k / 10 + '0'; if (j == 21) j += 4; } writel(ln); writel("|_______________________|___|_______________________|\n"); lastline: gwrite(); if (tflag) curmove(18, 0); else { writec('\n'); writec('\n'); } fixtty(&bg_raw); } void wrbsub() { int m; char d; if (board[k] > 0) { m = board[k]; d = 'r'; } else { m = -board[k]; d = 'w'; } if (m > i) ln[j + 1] = d; if (m > i + 5) ln[j] = d; if (m > i + 10) ln[j + 2] = d; } bsd-games-2.17/backgammon/common_source/init.c0000664000175000017500000000615607767741711020106 0ustar jsm28jsm28/* $NetBSD: init.c,v 1.8 2003/08/07 09:36:57 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: init.c,v 1.8 2003/08/07 09:36:57 agc Exp $"); #endif #endif /* not lint */ #include /* * variable initialization. */ /* name of executable object programs */ const char EXEC[] = EXEC_PATH; const char TEACH[] = TEACH_PATH; int pnum = 2; /* color of player: -1 = white 1 = red 0 = * both 2 = not yet init'ed */ int acnt = 1; /* length of args */ char args[100] = "-"; int aflag = 1; /* flag to ask for rules or instructions */ int bflag = 0; /* flag for automatic board printing */ int cflag = 0; /* case conversion flag */ int hflag = 1; /* flag for cleaning screen */ int mflag = 0; /* backgammon flag */ int raflag = 0; /* 'roll again' flag for recovered game */ int rflag = 0; /* recovered game flag */ int tflag = 0; /* cursor addressing flag */ int iroll = 0; /* special flag for inputting rolls */ int rfl = 0; const char *const color[] = {"White", "Red", "white", "red"}; const char *const *Colorptr; const char *const *colorptr; int *inopp; int *inptr; int *offopp; int *offptr; char args[100]; int bar; int begscr; int board[26]; char cin[100]; int colen; int cturn; int curc; int curr; int d0; int dice[2]; int dlast; int g[5]; int gvalue; int h[4]; int home; int in[2]; int mvl; int mvlim; int ncin; int off[2]; int p[5]; int rscore; int table[6][6]; int wscore; struct termios old, noech, bg_raw; bsd-games-2.17/backgammon/common_source/back.h0000664000175000017500000001451610005547567020037 0ustar jsm28jsm28/* $NetBSD: back.h,v 1.14 2004/01/27 20:30:28 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)back.h 8.1 (Berkeley) 5/31/93 */ #include #include #include #include #include #include #include #include #include #include #define rnum(r) (random()%r) #define D0 dice[0] #define D1 dice[1] #define swap {D0 ^= D1; D1 ^= D0; D0 ^= D1; d0 = 1-d0;} /* * * Some numerical conventions: * * Arrays have white's value in [0], red in [1]. * Numeric values which are one color or the other use * -1 for white, 1 for red. * Hence, white will be negative values, red positive one. * This makes a lot of sense since white is going in decending * order around the board, and red is ascending. * */ extern const char EXEC[]; /* object for main program */ extern const char TEACH[]; /* object for tutorial program */ extern int pnum; /* color of player: -1 = white 1 = red 0 = both 2 = not yet init'ed */ extern char args[100]; /* args passed to teachgammon and back */ extern int acnt; /* length of args */ extern int aflag; /* flag to ask for rules or instructions */ extern int bflag; /* flag for automatic board printing */ extern int cflag; /* case conversion flag */ extern int hflag; /* flag for cleaning screen */ extern int mflag; /* backgammon flag */ extern int raflag; /* 'roll again' flag for recovered game */ extern int rflag; /* recovered game flag */ extern int tflag; /* cursor addressing flag */ extern int rfl; /* saved value of rflag */ extern int iroll; /* special flag for inputting rolls */ extern int board[26]; /* board: negative values are white, positive are red */ extern int dice[2]; /* value of dice */ extern int mvlim; /* 'move limit': max. number of moves */ extern int mvl; /* working copy of mvlim */ extern int p[5]; /* starting position of moves */ extern int g[5]; /* ending position of moves (goals) */ extern int h[4]; /* flag for each move if a man was hit */ extern int cturn; /* whose turn it currently is: -1 = white 1 = red 0 = just quitted -2 = white just lost 2 = red just lost */ extern int d0; /* flag if dice have been reversed from original position */ extern int table[6][6]; /* odds table for possible rolls */ extern int rscore; /* red's score */ extern int wscore; /* white's score */ extern int gvalue; /* value of game (64 max.) */ extern int dlast; /* who doubled last (0 = neither) */ extern int bar; /* position of bar for current player */ extern int home; /* position of home for current player */ extern int off[2]; /* number of men off board */ extern int *offptr; /* pointer to off for current player */ extern int *offopp; /* pointer to off for opponent */ extern int in[2]; /* number of men in inner table */ extern int *inptr; /* pointer to in for current player */ extern int *inopp; /* pointer to in for opponent */ extern int ncin; /* number of characters in cin */ extern char cin[100]; /* input line of current move (used for reconstructing input after a backspace) */ extern const char *const color[]; /* colors as strings */ extern const char *const *colorptr; /* color of current player */ extern const char *const *Colorptr; /* color of current player, capitalized */ extern int colen; /* length of color of current player */ extern struct termios old, noech, bg_raw;/* original tty status */ extern int curr; /* row position of cursor */ extern int curc; /* column position of cursor */ extern int begscr; /* 'beginning' of screen (not including board) */ int addbuf(int); void backone(int); void bsect(int, int, int, int); void buflush(void); int canhit(int, int); int checkd(int); int checkmove(int); void clear(void); void clend(void); void cline(void); int count(void); void curmove(int, int); int dotable(char, int); void errexit(const char *) __attribute__((__noreturn__)); void fancyc(int); void fboard(void); void fixcol(int, int, int, int, int); void fixpos(int, int, int, int, int); void fixtty(struct termios *); void getarg(char ***); int getcaps(const char *); void getmove(void); void getout(int) __attribute__((__noreturn__)); void gwrite(void); void init(void); int last(void); int main(int, char *[]); int makmove(int); int movallow(void); void movback(int); void moverr(int); int movokay(int); void newline(void); void newpos(void); void nexturn(void); void norec(const char *) __attribute__((__noreturn__)); void odds(int, int, int); void proll(void); int quit(void); int readc(void); void recover(const char *); void refresh(void); void roll(void); int rsetbrd(void); void save(int); int text(const char *const *); void wrboard(void); void wrbsub(void); void wrhit(int); void wrint(int); void writec(char); void writel(const char *); void wrscore(void); int yorn(char); bsd-games-2.17/backgammon/common_source/table.c0000664000175000017500000001460607767741711020231 0ustar jsm28jsm28/* $NetBSD: table.c,v 1.7 2003/08/07 09:36:57 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: table.c,v 1.7 2003/08/07 09:36:57 agc Exp $"); #endif #endif /* not lint */ #include "back.h" const char *const help2[] = { " Enter moves as - or / where is the starting", "position, is the finishing position, and is the roll.", "Remember, each die roll must be moved separately.", 0 }; struct state { char ch; int fcode; int newst; }; static const struct state atmata[] = { {'R', 1, 0}, {'?', 7, 0}, {'Q', 0, -3}, {'B', 8, 25}, {'9', 2, 25}, {'8', 2, 25}, {'7', 2, 25}, {'6', 2, 25}, {'5', 2, 25}, {'4', 2, 25}, {'3', 2, 25}, {'2', 2, 19}, {'1', 2, 15}, {'0', 2, 25}, {'.', 0, 0}, {'9', 2, 25}, {'8', 2, 25}, {'7', 2, 25}, {'6', 2, 25}, {'5', 2, 25}, {'4', 2, 25}, {'3', 2, 25}, {'2', 2, 25}, {'1', 2, 25}, {'0', 2, 25}, {'/', 0, 32}, {'-', 0, 39}, {'.', 0, 0}, {'/', 5, 32}, {' ', 6, 3}, {',', 6, 3}, {'\n', 0, -1}, {'6', 3, 28}, {'5', 3, 28}, {'4', 3, 28}, {'3', 3, 28}, {'2', 3, 28}, {'1', 3, 28}, {'.', 0, 0}, {'H', 9, 61}, {'9', 4, 61}, {'8', 4, 61}, {'7', 4, 61}, {'6', 4, 61}, {'5', 4, 61}, {'4', 4, 61}, {'3', 4, 61}, {'2', 4, 53}, {'1', 4, 51}, {'0', 4, 61}, {'.', 0, 0}, {'9', 4, 61}, {'8', 4, 61}, {'7', 4, 61}, {'6', 4, 61}, {'5', 4, 61}, {'4', 4, 61}, {'3', 4, 61}, {'2', 4, 61}, {'1', 4, 61}, {'0', 4, 61}, {' ', 6, 3}, {',', 6, 3}, {'-', 5, 39}, {'\n', 0, -1}, {'.', 0, 0} }; int checkmove(ist) int ist; { int j, n; char c; domove: if (ist == 0) { if (tflag) curmove(curr, 32); else writel("\t\t"); writel("Move: "); } ist = mvl = ncin = 0; for (j = 0; j < 5; j++) p[j] = g[j] = -1; dochar: c = readc(); if (c == 'S') { raflag = 0; save(1); if (tflag) { curmove(cturn == -1 ? 18 : 19, 39); ist = -1; goto domove; } else { proll(); ist = 0; goto domove; } } if (c == old.c_cc[VERASE] && ncin > 0) { if (tflag) curmove(curr, curc - 1); else { if (old.c_cc[VERASE] == '\010') writel("\010 \010"); else writec(cin[ncin - 1]); } ncin--; n = rsetbrd(); if (n == 0) { n = -1; if (tflag) refresh(); } if ((ist = n) > 0) goto dochar; goto domove; } if (c == old.c_cc[VKILL] && ncin > 0) { if (tflag) { refresh(); curmove(curr, 39); ist = -1; goto domove; } else if (old.c_cc[VERASE] == '\010') { for (j = 0; j < ncin; j++) writel("\010 \010"); ist = -1; goto domove; } else { writec('\\'); writec('\n'); proll(); ist = 0; goto domove; } } n = dotable(c, ist); if (n >= 0) { cin[ncin++] = c; if (n > 2) if ((!tflag) || c != '\n') writec(c); ist = n; if (n) goto dochar; else goto domove; } if (n == -1 && mvl >= mvlim) return (0); if (n == -1 && mvl < mvlim - 1) return (-4); if (n == -6) { if (!tflag) { if (movokay(mvl + 1)) { wrboard(); movback(mvl + 1); } proll(); writel("\t\tMove: "); for (j = 0; j < ncin;) writec(cin[j++]); } else { if (movokay(mvl + 1)) { refresh(); movback(mvl + 1); } else curmove(cturn == -1 ? 18 : 19, ncin + 39); } ist = n = rsetbrd(); goto dochar; } if (n != -5) return (n); writec('\007'); goto dochar; } int dotable(c, i) char c; int i; { int a; int test; test = (c == 'R'); while ((a = atmata[i].ch) != '.') { if (a == c || (test && a == '\n')) { switch (atmata[i].fcode) { case 1: wrboard(); if (tflag) { curmove(cturn == -1 ? 18 : 19, 0); proll(); writel("\t\t"); } else proll(); break; case 2: if (p[mvl] == -1) p[mvl] = c - '0'; else p[mvl] = p[mvl] * 10 + c - '0'; break; case 3: if (g[mvl] != -1) { if (mvl < mvlim) mvl++; p[mvl] = p[mvl - 1]; } g[mvl] = p[mvl] + cturn * (c - '0'); if (g[mvl] < 0) g[mvl] = 0; if (g[mvl] > 25) g[mvl] = 25; break; case 4: if (g[mvl] == -1) g[mvl] = c - '0'; else g[mvl] = g[mvl] * 10 + c - '0'; break; case 5: if (mvl < mvlim) mvl++; p[mvl] = g[mvl - 1]; break; case 6: if (mvl < mvlim) mvl++; break; case 7: if (tflag) curmove(20, 0); else writec('\n'); (void) text(help2); if (tflag) { curmove(cturn == -1 ? 18 : 19, 39); } else { writec('\n'); proll(); writel("\t\tMove: "); } break; case 8: p[mvl] = bar; break; case 9: g[mvl] = home; } if (!test || a != '\n') return (atmata[i].newst); else return (-6); } i++; } return (-5); } int rsetbrd() { int i, j, n; n = 0; mvl = 0; for (i = 0; i < 4; i++) p[i] = g[i] = -1; for (j = 0; j < ncin; j++) n = dotable(cin[j], n); return (n); } bsd-games-2.17/backgammon/common_source/odds.c0000664000175000017500000000613507767741711020071 0ustar jsm28jsm28/* $NetBSD: odds.c,v 1.5 2003/08/07 09:36:57 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)odds.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: odds.c,v 1.5 2003/08/07 09:36:57 agc Exp $"); #endif #endif /* not lint */ #include "back.h" void odds(r1, r2, val) int r1, r2, val; { int i, j; if (r1 == 0) { for (i = 0; i < 6; i++) for (j = 0; j < 6; j++) table[i][j] = 0; return; } else { r1--; if (r2-- == 0) { for (i = 0; i < 6; i++) { table[i][r1] += val; table[r1][i] += val; } } else { table[r2][r1] += val; table[r1][r2] += val; } } } int count() { int i; int j; int total; total = 0; for (i = 0; i < 6; i++) for (j = 0; j < 6; j++) total += table[i][j]; return (total); } int canhit(i, c) int i, c; { int j, k, b; int a, diff, place, addon, menstuck; if (c == 0) odds(0, 0, 0); if (board[i] > 0) { a = -1; b = 25; } else { a = 1; b = 0; } place = abs(25 - b - i); menstuck = abs(board[b]); for (j = b; j != i; j += a) { if (board[j] * a > 0) { diff = abs(j - i); addon = place + ((board[j] * a > 2 || j == b) ? 5 : 0); if ((j == b && menstuck == 1) && (j != b && menstuck == 0)) for (k = 1; k < diff; k++) if (k < 7 && diff - k < 7 && (board[i + a * k] * a >= 0 || board[i + a * (diff - k)] >= 0)) odds(k, diff - k, addon); if ((j == b || menstuck < 2) && diff < 7) odds(diff, 0, addon); } if (j == b && menstuck > 1) break; } return (count()); } bsd-games-2.17/backgammon/common_source/Makefrag0000664000175000017500000000347206773402557020433 0ustar jsm28jsm28# Makefrag - makefile fragment for backgammon/common_source # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. backgammon_common_source_EXEC_PATH := $(GAMESDIR)/backgammon backgammon_common_source_TEACH_PATH := $(GAMESDIR)/teachgammon backgammon_common_source_DEFS := -DEXEC_PATH=\"$(backgammon_common_source_EXEC_PATH)\" -DTEACH_PATH=\"$(backgammon_common_source_TEACH_PATH)\" backgammon_common_source_all: backgammon_common_source_install: bsd-games-2.17/backgammon/common_source/subs.c0000664000175000017500000002103307767741711020106 0ustar jsm28jsm28/* $NetBSD: subs.c,v 1.14 2003/08/07 09:36:57 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: subs.c,v 1.14 2003/08/07 09:36:57 agc Exp $"); #endif #endif /* not lint */ #include "back.h" int buffnum = -1; char outbuff[BUFSIZ]; static const char plred[] = "Player is red, computer is white."; static const char plwhite[] = "Player is white, computer is red."; static const char nocomp[] = "(No computer play.)"; const char *const descr[] = { "Usage: backgammon [-] [n r w b pr pw pb t3a]\n", "\t-\tgets this list\n\tn\tdon't ask for rules or instructions", "\tr\tplayer is red (implies n)\n\tw\tplayer is white (implies n)", "\tb\ttwo players, red and white (implies n)", "\tpr\tprint the board before red's turn", "\tpw\tprint the board before white's turn", "\tpb\tprint the board before both player's turn", "\tterm\tterminal is a term", "\tsfile\trecover saved game from file", 0 }; void errexit(s) const char *s; { write(2, "\n", 1); perror(s); getout(0); } int addbuf(c) int c; { buffnum++; if (buffnum == BUFSIZ) { if (write(1, outbuff, BUFSIZ) != BUFSIZ) errexit("addbuf (write):"); buffnum = 0; } outbuff[buffnum] = c; return (0); } void buflush() { if (buffnum < 0) return; buffnum++; if (write(1, outbuff, buffnum) != buffnum) errexit("buflush (write):"); buffnum = -1; } int readc() { char c; if (tflag) { cline(); newpos(); } buflush(); if (read(0, &c, 1) != 1) errexit("readc"); #ifdef WHY_IS_THIS_HARDWIRED_IN_HERE if (c == '\177') getout(0); #endif if (c == '\033' || c == '\015') return ('\n'); if (cflag) return (c); if (c == '\014') return ('R'); if (c >= 'a' && c <= 'z') return (c & 0137); return (c); } void writec(c) char c; { if (tflag) fancyc(c); else addbuf(c); } void writel(l) const char *l; { #ifdef DEBUG const char *s; if (trace == NULL) trace = fopen("bgtrace", "w"); fprintf(trace, "writel: \""); for (s = l; *s; s++) { if (*s < ' ' || *s == '\177') fprintf(trace, "^%c", (*s) ^ 0100); else putc(*s, trace); } fprintf(trace, "\"\n"); fflush(trace); #endif while (*l) writec(*l++); } void proll() { if (d0) swap; if (cturn == 1) writel("Red's roll: "); else writel("White's roll: "); writec(D0 + '0'); writec('\040'); writec(D1 + '0'); if (tflag) cline(); } void wrint(n) int n; { int i, j, t; for (i = 4; i > 0; i--) { t = 1; for (j = 0; j < i; j++) t *= 10; if (n > t - 1) writec((n / t) % 10 + '0'); } writec(n % 10 + '0'); } void gwrite() { int r, c; r = c = 0; if (tflag) { r = curr; c = curc; curmove(16, 0); } if (gvalue > 1) { writel("Game value: "); wrint(gvalue); writel(". "); if (dlast == -1) writel(color[0]); else writel(color[1]); writel(" doubled last."); } else { switch (pnum) { case -1: /* player is red */ writel(plred); break; case 0: /* player is both colors */ writel(nocomp); break; case 1: /* player is white */ writel(plwhite); } } if (rscore || wscore) { writel(" "); wrscore(); } if (tflag) { cline(); curmove(r, c); } } int quit() { if (tflag) { curmove(20, 0); clend(); } else writec('\n'); writel("Are you sure you want to quit?"); if (yorn(0)) { if (rfl) { writel("Would you like to save this game?"); if (yorn(0)) save(0); } cturn = 0; return (1); } return (0); } int yorn(special) char special; /* special response */ { char c; int i; i = 1; while ((c = readc()) != 'Y' && c != 'N') { if (special && c == special) return (2); if (i) { if (special) { writel(" (Y, N, or "); writec(special); writec(')'); } else writel(" (Y or N)"); i = 0; } else writec('\007'); } if (c == 'Y') writel(" Yes.\n"); else writel(" No.\n"); if (tflag) buflush(); return (c == 'Y'); } void wrhit(i) int i; { writel("Blot hit on "); wrint(i); writec('.'); writec('\n'); } void nexturn() { int c; cturn = -cturn; c = cturn / abs(cturn); home = bar; bar = 25 - bar; offptr += c; offopp -= c; inptr += c; inopp -= c; Colorptr += c; colorptr += c; } void getarg(arg) char ***arg; { char **s; /* process arguments here. dashes are ignored, nbrw are ignored if * the game is being recovered */ s = *arg; while (*s && s[0][0] == '-') { switch (s[0][1]) { /* don't ask if rules or instructions needed */ case 'n': if (rflag) break; aflag = 0; args[acnt++] = 'n'; break; /* player is both red and white */ case 'b': if (rflag) break; pnum = 0; aflag = 0; args[acnt++] = 'b'; break; /* player is red */ case 'r': if (rflag) break; pnum = -1; aflag = 0; args[acnt++] = 'r'; break; /* player is white */ case 'w': if (rflag) break; pnum = 1; aflag = 0; args[acnt++] = 'w'; break; /* print board after move according to following * character */ case 'p': if (s[0][2] != 'r' && s[0][2] != 'w' && s[0][2] != 'b') break; args[acnt++] = 'p'; args[acnt++] = s[0][2]; if (s[0][2] == 'r') bflag = 1; if (s[0][2] == 'w') bflag = -1; if (s[0][2] == 'b') bflag = 0; break; case 't': if (s[0][2] == '\0') { /* get terminal caps */ s++; tflag = getcaps(*s); } else tflag = getcaps(&s[0][2]); break; case 's': s++; /* recover file */ if (s[0] == NULL) { writel("No save file named\n"); getout(0); } else recover(s[0]); break; } s++; } if (s[0] != 0) recover(s[0]); } void init() { int i; for (i = 0; i < 26;) board[i++] = 0; board[1] = 2; board[6] = board[13] = -5; board[8] = -3; board[12] = board[19] = 5; board[17] = 3; board[24] = -2; off[0] = off[1] = -15; in[0] = in[1] = 5; gvalue = 1; dlast = 0; } void wrscore() { writel("Score: "); writel(color[1]); writec(' '); wrint(rscore); writel(", "); writel(color[0]); writec(' '); wrint(wscore); } void fixtty(t) struct termios *t; { if (tflag) newpos(); buflush(); if (tcsetattr(0, TCSADRAIN, t) < 0) errexit("fixtty"); } void getout(dummy) int dummy __attribute__((__unused__)); { /* go to bottom of screen */ if (tflag) { curmove(23, 0); cline(); } else writec('\n'); /* fix terminal status */ fixtty(&old); exit(0); } void roll() { char c; int row; int col; row = col = 0; if (iroll) { if (tflag) { row = curr; col = curc; curmove(17, 0); } else writec('\n'); writel("ROLL: "); c = readc(); if (c != '\n') { while (c < '1' || c > '6') c = readc(); D0 = c - '0'; writec(' '); writec(c); c = readc(); while (c < '1' || c > '6') c = readc(); D1 = c - '0'; writec(' '); writec(c); if (tflag) { curmove(17, 0); cline(); curmove(row, col); } else writec('\n'); return; } if (tflag) { curmove(17, 0); cline(); curmove(row, col); } else writec('\n'); } D0 = rnum(6) + 1; D1 = rnum(6) + 1; d0 = 0; } bsd-games-2.17/backgammon/common_source/check.c0000664000175000017500000000675507767741711020225 0ustar jsm28jsm28/* $NetBSD: check.c,v 1.5 2003/08/07 09:36:57 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)check.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: check.c,v 1.5 2003/08/07 09:36:57 agc Exp $"); #endif #endif /* not lint */ #include "back.h" void getmove() { int i, c; c = 0; for (;;) { i = checkmove(c); switch (i) { case -1: if (movokay(mvlim)) { if (tflag) curmove(20, 0); else writec('\n'); for (i = 0; i < mvlim; i++) if (h[i]) wrhit(g[i]); nexturn(); if (*offopp == 15) cturn *= -2; if (tflag && pnum) bflag = pnum; return; } case -4: case 0: if (tflag) refresh(); if (i != 0 && i != -4) break; if (tflag) curmove(20, 0); else writec('\n'); writel(*Colorptr); if (i == -4) writel(" must make "); else writel(" can only make "); writec(mvlim + '0'); writel(" move"); if (mvlim > 1) writec('s'); writec('.'); writec('\n'); break; case -3: if (quit()) return; } if (!tflag) proll(); else { curmove(cturn == -1 ? 18 : 19, 39); cline(); c = -1; } } } int movokay(mv) int mv; { int i, m; if (d0) swap; for (i = 0; i < mv; i++) { if (p[i] == g[i]) { moverr(i); curmove(20, 0); writel("Attempt to move to same location.\n"); return (0); } if (cturn * (g[i] - p[i]) < 0) { moverr(i); curmove(20, 0); writel("Backwards move.\n"); return (0); } if (abs(board[bar]) && p[i] != bar) { moverr(i); curmove(20, 0); writel("Men still on bar.\n"); return (0); } if ((m = makmove(i))) { moverr(i); switch (m) { case 1: writel("Move not rolled.\n"); break; case 2: writel("Bad starting position.\n"); break; case 3: writel("Destination occupied.\n"); break; case 4: writel("Can't remove men yet.\n"); } return (0); } } return (1); } bsd-games-2.17/backgammon/Makefile.bsd0000664000175000017500000000025607240362720016312 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.6 2001/01/09 03:13:39 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 SUBDIR= common_source .WAIT backgammon teachgammon .include bsd-games-2.17/backgammon/Makefile.inc.bsd0000664000175000017500000000051507240362720017060 0ustar jsm28jsm28# $NetBSD: Makefile.inc,v 1.6 2000/12/30 17:51:26 sommerfeld Exp $ .include LIBCOMMON != cd ${.CURDIR}/../common_source; ${PRINTOBJDIR} CPPFLAGS+=-DV7 -I${.CURDIR}/../common_source DPADD+= ${LIBCOMMON}/libcommon.a ${LIBTERMCAP} LDADD+= -L${LIBCOMMON} -lcommon -ltermcap HIDEGAME=hidegame .include "../Makefile.inc" bsd-games-2.17/backgammon/Makefrag0000664000175000017500000000277506773402557015570 0ustar jsm28jsm28# Makefrag - makefile fragment for backgammon # # Copyright (c) 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. backgammon_all: backgammon_install: bsd-games-2.17/boggle/0000775000175000017500000000000010205246605013236 5ustar jsm28jsm28bsd-games-2.17/boggle/boggle/0000775000175000017500000000000010205246605014475 5ustar jsm28jsm28bsd-games-2.17/boggle/boggle/Makefile.bsd0000664000175000017500000000060106701650657016715 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.9 1999/02/13 02:54:20 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 .include PROG= boggle SRCS= bog.c help.c mach.c prtable.c timer.c word.c DPADD= ${LIBCURSES} LDADD= -lcurses HIDEGAME=hidegame MAN= boggle.6 .if ${MKSHARE} != "no" FILES= helpfile FILESDIR=/usr/share/games/boggle .endif .include "../../Makefile.inc" .include bsd-games-2.17/boggle/boggle/timer.c0000664000175000017500000000644510005547567016003 0ustar jsm28jsm28/* $NetBSD: timer.c,v 1.9 2004/01/27 20:30:29 jsm Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)timer.c 8.2 (Berkeley) 2/22/94"; #else __RCSID("$NetBSD: timer.c,v 1.9 2004/01/27 20:30:29 jsm Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include #include "bog.h" #include "extern.h" static int waitch(int); extern int tlimit; extern time_t start_t; extern jmp_buf env; /* * Update the display of the remaining time while waiting for a character * If time runs out do a longjmp() to the game controlling routine, returning * non-zero; oth. return the character * Leave the cursor where it was initially */ int timerch() { time_t prevt, t; int col, remaining, row; getyx(stdscr, row, col); prevt = 0L; for (;;) { if (waitch(1) == 1) break; time(&t); if (t == prevt) continue; prevt = t; remaining = tlimit - (int) (t - start_t); if (remaining < 0) { longjmp(env, 1); /*NOTREACHED*/ } move(TIMER_LINE, TIMER_COL); printw("%d:%02d", remaining / 60, remaining % 60); move(row, col); refresh(); } return (getch() & 0177); } /* * Wait up to 'delay' microseconds for input to appear * Returns 1 if input is ready, 0 oth. */ static int waitch(delay) int delay; { struct pollfd set[1]; set[0].fd = STDIN_FILENO; set[0].events = POLLIN; return (poll(set, 1, delay)); } void delay(tenths) int tenths; { struct timespec duration; duration.tv_nsec = (tenths % 10 ) * 100000000L; duration.tv_sec = (long) (tenths / 10); nanosleep(&duration, NULL); } bsd-games-2.17/boggle/boggle/bog.h.in0000664000175000017500000000544507767741711016053 0ustar jsm28jsm28/* $NetBSD: bog.h,v 1.3 2003/08/07 09:37:05 agc Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)bog.h 8.1 (Berkeley) 6/11/93 */ #define LOADDICT 1 /* Load the dictionary for speed */ /* * Locations for the dictionary (generated by mkdict), * index (generated by mkindex), and helpfile */ #define DICT "@boggle_dir@/dictionary" #define DICTINDEX "@boggle_dir@/dictindex" #define HELPFILE "@boggle_dir@/helpfile" /* * The theoretical maximum for MAXWORDLEN is ('a' - 1) == 96 */ #define MAXWORDLEN 40 /* Maximum word length */ #define MAXPWORDS 200 /* Maximum number of player's words */ #define MAXMWORDS 200 /* Maximum number of machine's words */ #define MAXPSPACE 2000 /* Space for player's words */ #define MAXMSPACE 4000 /* Space for machines's words */ #define MAXCOLS 20 /* * The following determine the screen layout */ #define PROMPT_COL 20 #define PROMPT_LINE 2 #define BOARD_COL 0 #define BOARD_LINE 0 #define SCORE_COL 20 #define SCORE_LINE 0 #define LIST_COL 0 #define LIST_LINE 10 #define TIMER_COL 20 #define TIMER_LINE 2 /* * Internal dictionary index * Initialized from the file created by mkindex */ struct dictindex { long start; long length; }; bsd-games-2.17/boggle/boggle/boggle.60000664000175000017500000000764307767741711016056 0ustar jsm28jsm28.\" $NetBSD: boggle.6,v 1.7 2003/08/07 09:37:05 agc Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Barry Brachman. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)boggle.6 8.1 (Berkeley) 6/11/93 .\" .Dd April 1, 2001 .Dt BOGGLE 6 .Os .Sh NAME .Nm boggle .Nd word search game .Sh SYNOPSIS .Nm .Op Fl bd .Op Fl s Ar seed .Op Fl t Ar time .Op Fl w Ar length .Op + Op + .Op boardspec .Sh DESCRIPTION The object of .Nm is to find as many words as possible on the Boggle board within the three minute time limit. A Boggle board is a four by four arrangement of Boggle cubes, each side of each cube displaying a letter of the alphabet or `qu'. Words are formed by finding a sequence of cubes (letters) that are in the game's dictionary. The (N+1)th cube in the word must be horizontally, vertically, or diagonally adjacent to the Nth cube. Cubes cannot be reused. Words consist solely of lower case letters and must be at least 3 letters long. .Pp Command line flags can be given to change the rules of the game. .Bl -tag -width boardspec .It Fl b Run .Nm in batch mode. A .Ar boardspec must also be given. The dictionary is read from stdin and a list of words appearing in .Ar boardspec is printed to stdout. .It Fl d Enable debugging output. .It Fl s Ar seed Specify a seed .Ar seed other than the time of day. .It Fl t Ar time Set the time limit for each game from the default 3 minutes to .Ar time seconds. .It Fl w Ar length Change the minimum word length from 3 letters to .Ar length . .It Ar + This flag allows a cube to be used multiple times, but not in succession. .It Ar ++ This flag allows the same cubes to be considered adjacent to itself. .It Ar boardspec A starting board position can be specified on the command line by listing the board left to right and top to bottom. .El .Pp Help is available during play by typing .Sq Ic \&? . More detailed information on the game is given there. .Sh BUGS If there are a great many words in the cube the final display of the words may scroll off of the screen. (On a 25 line screen about 130 words can be displayed.) .Pp No word can contain a .Sq q that is not immediately followed by a .Sq u . .Pp When using the .Ar + or .Ar ++ options the display of words found in the board doesn't indicate reused cubes. .Sh AUTHOR Boggle is a trademark of Parker Brothers. .Pp Barry Brachman .br Dept. of Computer Science .br University of British Columbia bsd-games-2.17/boggle/boggle/helpfile0000664000175000017500000000661306602512212016212 0ustar jsm28jsm28 Commands: Enter word: or or Delete previous character: or Delete line: <^u> or <^w> Redraw screen: <^l> or <^r> Pause game: <^s> Resume game: <^q> or <^s> Suspend game (BSD only): <^z> Give up on current cube: <^d> Show remaining time: first thing on a line Show help: ? (Suspends timer until done) Exit game: <^c> (^u means "control u", etc.) [Note for users of versions of this program that do not display a timer: The first word entered after the timer has run out causes a list of all the words you found, the words you missed, and your running statistics to be displayed.] Any time you are prompted while the board is displayed you can type: word to see where "word" is on the board. Usage: bog [-b] [-d] [-s#] [-t#] [-w#] [+[+]] [boardspec] -b: batch mode (boardspec must be present); dictionary read from stdin -d: debug mode -s#: use # as the random number seed -t#: time limit is # seconds instead of default 180 -w#: minimum word length is # letters instead of default 3 +: can reuse a cube, but not twice in succession ++: can reuse cubes arbitrarily boardspec: the first board to use (use 'q' for 'qu'); e.g.: bog nolezeebnqieegei . Default Rules A Boggle board is a four by four arrangement of Boggle cubes. You have 3 minutes to find as many words as possible in the Boggle board. Words are formed by finding a sequence of cubes (letters) that are in the game's dictionary. The (N+1)th cube in the word must be horizontally, vertically, or diagonally adjacent to the Nth cube. Cubes cannot be reused. Words consist solely of lower case letters and must be at least 3 letters long. . Options Command line flags can be given to change the rules of the game. The '+' flag allows a cube to be used multiple times, but not in succession. The '++' flag makes each cube adjacent to itself. The time limit can be changed from the default 3 minutes by using the flag '-t#', where # is the duration (in seconds) of each game. The minimum word length can be changed from 3 letters by specifying 'w#', where # is the minimum number of letters to use. . Bugs and Limitations The following bugs and problems are known to exist: - If there are a great many words in the cube the final display of the words may scroll off of the screen. (On a 25 line screen about 130 words can be displayed.) - Computing the complete word list can be too slow on small machines. - No word can contain a 'q' that is not immediately followed by a 'u'. - When using the '+' or '++' options the display of words found in the board doesn't indicate reused cubes. . About This Program Boggle is under the standard BSD licence. Bugs should be reported to your distributor; the original author is no longer supporting the program. Copyright (c) 1988 Barry Brachman | UUCP: {alberta,uw-beaver,uunet}! Dept. of Computer Science| ubc-vision!ubc-csgrads!brachman Univ. of British Columbia| Internet: brachman@cs.ubc.ca Vancouver, B.C. V6T 1W5 | brachman%ubc.csnet@csnet-relay.arpa (604) 228-5010 | brachman@ubc.csnet Boggle is a trademark of Parker Brothers. bsd-games-2.17/boggle/boggle/bog.c0000664000175000017500000003577510155330535015431 0ustar jsm28jsm28/* $NetBSD: bog.c,v 1.19 2004/11/05 21:30:31 dsl Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)bog.c 8.2 (Berkeley) 5/4/95"; #else __RCSID("$NetBSD: bog.c,v 1.19 2004/11/05 21:30:31 dsl Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include "bog.h" #include "extern.h" static int compar(const void *, const void *); int main(int, char *[]); struct dictindex dictindex[26]; /* * Cube position numbering: * * 0 1 2 3 * 4 5 6 7 * 8 9 A B * C D E F */ static int adjacency[16][16] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ { 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* 0 */ { 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* 1 */ { 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, /* 2 */ { 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, /* 3 */ { 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 }, /* 4 */ { 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0 }, /* 5 */ { 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 }, /* 6 */ { 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0 }, /* 7 */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0 }, /* 8 */ { 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0 }, /* 9 */ { 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1 }, /* A */ { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1 }, /* B */ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0 }, /* C */ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0 }, /* D */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1 }, /* E */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0 } /* F */ }; static int letter_map[26][16]; char board[17]; int wordpath[MAXWORDLEN + 1]; int wordlen; /* Length of last word returned by nextword() */ int usedbits; const char *pword[MAXPWORDS]; char pwords[MAXPSPACE], *pwordsp; int npwords; const char *mword[MAXMWORDS]; char mwords[MAXMSPACE], *mwordsp; int nmwords; int ngames = 0; int tnmwords = 0, tnpwords = 0; #include jmp_buf env; time_t start_t; static FILE *dictfp; int batch; int debug; int minlength; int reuse; int tlimit; int main(argc, argv) int argc; char *argv[]; { long seed; int ch, done, i, selfuse, sflag; char *bspec, *p; /* revoke setgid privileges */ setregid(getgid(), getgid()); seed = 0; batch = debug = reuse = selfuse = sflag = 0; bspec = NULL; minlength = 3; tlimit = 180; /* 3 minutes is standard */ while ((ch = getopt(argc, argv, "bds:t:w:")) != -1) switch(ch) { case 'b': batch = 1; break; case 'd': debug = 1; break; case 's': sflag = 1; seed = atol(optarg); break; case 't': if ((tlimit = atoi(optarg)) < 1) errx(1, "bad time limit"); break; case 'w': if ((minlength = atoi(optarg)) < 3) errx(1, "min word length must be > 2"); break; case '?': default: usage(); } argc -= optind; argv += optind; /* process final arguments */ if (argc > 0) { if (strcmp(argv[0], "+") == 0) reuse = 1; else if (strcmp(argv[0], "++") == 0) selfuse = 1; } if (reuse || selfuse) { argc -= 1; argv += 1; } if (argc > 0) { if (islower((unsigned char)argv[0][0])) { if (strlen(argv[0]) != 16) { usage(); } else { /* This board is assumed to be valid... */ bspec = argv[0]; } } else { usage(); } } if (batch && bspec == NULL) errx(1, "must give both -b and a board setup"); if (selfuse) for (i = 0; i < 16; i++) adjacency[i][i] = 1; if (batch) { newgame(bspec); while ((p = batchword(stdin)) != NULL) (void) printf("%s\n", p); exit (0); } setup(sflag, seed); prompt("Loading the dictionary..."); if ((dictfp = opendict(DICT)) == NULL) { warn("%s", DICT); cleanup(); exit(1); } #ifdef LOADDICT if (loaddict(dictfp) < 0) { warnx("can't load %s", DICT); cleanup(); exit(1); } (void)fclose(dictfp); dictfp = NULL; #endif if (loadindex(DICTINDEX) < 0) { warnx("can't load %s", DICTINDEX); cleanup(); exit(1); } prompt("Type to begin..."); while (inputch() != ' '); for (done = 0; !done;) { newgame(bspec); bspec = NULL; /* reset for subsequent games */ playgame(); #ifdef NEW_STYLE prompt("Type uit, locate, any other key to continue..."); #else prompt("Type to continue, any cap to quit..."); #endif delay(50); /* wait for user to quit typing */ flushin(stdin); for (;;) { ch = inputch(); #ifdef NEW_STYLE if (ch == '\033') findword(); else if (ch == '\014' || ch == '\022') /* ^l or ^r */ redraw(); else { if (ch == 'q') { done = 1; break; } else { break; } } #else if (ch == '\033') findword(); else if (ch == '\014' || ch == '\022') /* ^l or ^r */ redraw(); else { if (isupper(ch)) { done = 1; break; } if (ch == ' ') break; } #endif } } cleanup(); exit (0); } /* * Read a line from the given stream and check if it is legal * Return a pointer to a legal word or a null pointer when EOF is reached */ char * batchword(fp) FILE *fp; { int *p, *q; char *w; q = &wordpath[MAXWORDLEN + 1]; p = wordpath; while (p < q) *p++ = -1; while ((w = nextword(fp)) != NULL) { if (wordlen < minlength) continue; p = wordpath; while (p < q && *p != -1) *p++ = -1; usedbits = 0; if (checkword(w, -1, wordpath) != -1) return (w); } return (NULL); } /* * Play a single game * Reset the word lists from last game * Keep track of the running stats */ void playgame() { int i, *p, *q; time_t t; char buf[MAXWORDLEN + 1]; ngames++; npwords = 0; pwordsp = pwords; nmwords = 0; mwordsp = mwords; time(&start_t); q = &wordpath[MAXWORDLEN + 1]; p = wordpath; while (p < q) *p++ = -1; showboard(board); startwords(); if (setjmp(env)) { badword(); goto timesup; } while (1) { if (getline(buf) == NULL) { if (feof(stdin)) clearerr(stdin); break; } time(&t); if (t - start_t >= tlimit) { badword(); break; } if (buf[0] == '\0') { int remaining; remaining = tlimit - (int) (t - start_t); (void)snprintf(buf, sizeof(buf), "%d:%02d", remaining / 60, remaining % 60); showstr(buf, 1); continue; } if (strlen(buf) < (size_t)minlength) { badword(); continue; } p = wordpath; while (p < q && *p != -1) *p++ = -1; usedbits = 0; if (checkword(buf, -1, wordpath) < 0) badword(); else { if (debug) { (void) printf("["); for (i = 0; wordpath[i] != -1; i++) (void) printf(" %d", wordpath[i]); (void) printf(" ]\n"); } for (i = 0; i < npwords; i++) { if (strcmp(pword[i], buf) == 0) break; } if (i != npwords) { /* already used the word */ badword(); showword(i); } else if (!validword(buf)) badword(); else { int len; len = strlen(buf) + 1; if (npwords == MAXPWORDS - 1 || pwordsp + len >= &pwords[MAXPSPACE]) { warnx("Too many words!"); cleanup(); exit(1); } pword[npwords++] = pwordsp; (void) strcpy(pwordsp, buf); pwordsp += len; addword(buf); } } } timesup: ; /* * Sort the player's words and terminate the list with a null * entry to help out checkdict() */ qsort(pword, npwords, sizeof(pword[0]), compar); pword[npwords] = NULL; /* * These words don't need to be sorted since the dictionary is sorted */ checkdict(); tnmwords += nmwords; tnpwords += npwords; results(); } /* * Check if the given word is present on the board, with the constraint * that the first letter of the word is adjacent to square 'prev' * Keep track of the current path of squares for the word * A 'q' must be followed by a 'u' * Words must end with a null * Return 1 on success, -1 on failure */ int checkword(word, prev, path) const char *word; int prev, *path; { const char *p; char *q; int i, *lm; if (debug) { (void) printf("checkword(%s, %d, [", word, prev); for (i = 0; wordpath[i] != -1; i++) (void) printf(" %d", wordpath[i]); (void) printf(" ]\n"); } if (*word == '\0') return (1); lm = letter_map[*word - 'a']; if (prev == -1) { char subword[MAXWORDLEN + 1]; /* * Check for letters not appearing in the cube to eliminate some * recursive calls * Fold 'qu' into 'q' */ p = word; q = subword; while (*p != '\0') { if (*letter_map[*p - 'a'] == -1) return (-1); *q++ = *p; if (*p++ == 'q') { if (*p++ != 'u') return (-1); } } *q = '\0'; while (*lm != -1) { *path = *lm; usedbits |= (1 << *lm); if (checkword(subword + 1, *lm, path + 1) > 0) return (1); usedbits &= ~(1 << *lm); lm++; } return (-1); } /* * A cube is only adjacent to itself in the adjacency matrix if selfuse * was set, so a cube can't be used twice in succession if only the * reuse flag is set */ for (i = 0; lm[i] != -1; i++) { if (adjacency[prev][lm[i]]) { int used; used = 1 << lm[i]; /* * If necessary, check if the square has already * been used. */ if (!reuse && (usedbits & used)) continue; *path = lm[i]; usedbits |= used; if (checkword(word + 1, lm[i], path + 1) > 0) return (1); usedbits &= ~used; } } *path = -1; /* in case of a backtrack */ return (-1); } /* * A word is invalid if it is not in the dictionary * At this point it is already known that the word can be formed from * the current board */ int validword(word) const char *word; { int j; const char *q, *w; j = word[0] - 'a'; if (dictseek(dictfp, dictindex[j].start, SEEK_SET) < 0) { (void) fprintf(stderr, "Seek error\n"); cleanup(); exit(1); } while ((w = nextword(dictfp)) != NULL) { int ch; if (*w != word[0]) /* end of words starting with word[0] */ break; q = word; while ((ch = *w++) == *q++ && ch != '\0') ; if (*(w - 1) == '\0' && *(q - 1) == '\0') return (1); } if (dictfp != NULL && feof(dictfp)) /* Special case for z's */ clearerr(dictfp); return (0); } /* * Check each word in the dictionary against the board * Delete words from the machine list that the player has found * Assume both the dictionary and the player's words are already sorted */ void checkdict() { char *p, *w; const char **pw; int i; int prevch, previndex, *pi, *qi, st; mwordsp = mwords; nmwords = 0; pw = pword; prevch ='a'; qi = &wordpath[MAXWORDLEN + 1]; (void) dictseek(dictfp, 0L, SEEK_SET); while ((w = nextword(dictfp)) != NULL) { if (wordlen < minlength) continue; if (*w != prevch) { /* * If we've moved on to a word with a different first * letter then we can speed things up by skipping all * words starting with a letter that doesn't appear in * the cube. */ i = (int) (*w - 'a'); while (i < 26 && letter_map[i][0] == -1) i++; if (i == 26) break; previndex = prevch - 'a'; prevch = i + 'a'; /* * Fall through if the word's first letter appears in * the cube (i.e., if we can't skip ahead), otherwise * seek to the beginning of words in the dictionary * starting with the next letter (alphabetically) * appearing in the cube and then read the first word. */ if (i != previndex + 1) { if (dictseek(dictfp, dictindex[i].start, SEEK_SET) < 0) { warnx("seek error in checkdict()"); cleanup(); exit(1); } continue; } } pi = wordpath; while (pi < qi && *pi != -1) *pi++ = -1; usedbits = 0; if (checkword(w, -1, wordpath) == -1) continue; st = 1; while (*pw != NULL && (st = strcmp(*pw, w)) < 0) pw++; if (st == 0) /* found it */ continue; if (nmwords == MAXMWORDS || mwordsp + wordlen + 1 >= &mwords[MAXMSPACE]) { warnx("too many words!"); cleanup(); exit(1); } mword[nmwords++] = mwordsp; p = w; while ((*mwordsp++ = *p++) != '\0') ; } } /* * Crank up a new game * If the argument is non-null then it is assumed to be a legal board spec * in ascending cube order, oth. make a random board */ void newgame(b) const char *b; { int i, p, q; const char *tmp; int *lm[26]; static const char *cubes[16] = { "ednosw", "aaciot", "acelrs", "ehinps", "eefhiy", "elpstu", "acdemp", "gilruw", "egkluy", "ahmors", "abilty", "adenvz", "bfiorx", "dknotu", "abjmoq", "egintv" }; if (b == NULL) { /* * Shake the cubes and make the board */ i = 0; while (i < 100) { p = (int) (random() % 16); q = (int) (random() % 16); if (p != q) { tmp = cubes[p]; cubes[p] = cubes[q]; cubes[q] = tmp; i++; } /* else try again */ } for (i = 0; i < 16; i++) board[i] = cubes[i][random() % 6]; } else { for (i = 0; i < 16; i++) board[i] = b[i]; } board[16] = '\0'; /* * Set up the map from letter to location(s) * Each list is terminated by a -1 entry */ for (i = 0; i < 26; i++) { lm[i] = letter_map[i]; *lm[i] = -1; } for (i = 0; i < 16; i++) { int j; j = (int) (board[i] - 'a'); *lm[j] = i; *(++lm[j]) = -1; } if (debug) { for (i = 0; i < 26; i++) { int ch, j; (void) printf("%c:", 'a' + i); for (j = 0; (ch = letter_map[i][j]) != -1; j++) (void) printf(" %d", ch); (void) printf("\n"); } } } int compar(p, q) const void *p, *q; { return (strcmp(*(const char *const *)p, *(const char *const *)q)); } void usage() { (void) fprintf(stderr, "usage: bog [-bd] [-s#] [-t#] [-w#] [+[+]] [boardspec]\n"); exit(1); } bsd-games-2.17/boggle/boggle/prtable.c0000664000175000017500000001022610005547567016304 0ustar jsm28jsm28/* $NetBSD: prtable.c,v 1.8 2004/01/27 20:30:29 jsm Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)prtable.c 8.1 (Berkeley) 6/11/93 */ #include #ifndef lint __RCSID("$NetBSD: prtable.c,v 1.8 2004/01/27 20:30:29 jsm Exp $"); #endif /* not lint */ #include #include "extern.h" #define NCOLS 5 static int get_maxlen(const char *const [], int, int (*)(const char *const *, int)); /* * Routine to print a table * Modified from 'ls.c' mods (BJB/83) * Arguments: * base - address of first entry * num - number of entries * d_cols - number of columns to use if > 0, "best" size if == 0 * width - max line width if not zero * prentry - address of the routine to call to print the string * length - address of the routine to call to determine the length * of string to be printed * * prtable and length are called with the address of the base and * an index */ void prtable(base, num, d_cols, width, prentry, length) const char *const base[]; int num, d_cols, width; void (*prentry)(const char *const [], int); int (*length)(const char *const [], int); { int c, j; int a, b, cols, loc, maxlen, nrows, z; int col, row; if (num == 0) return; maxlen = get_maxlen(base, num, length) + 1; if (d_cols > 0) cols = d_cols; else cols = width / maxlen; if (cols == 0) cols = NCOLS; nrows = (num - 1) / cols + 1; for (a = 1; a <= nrows; a++) { b = c = z = loc = 0; for (j = 0; j < num; j++) { c++; if (c >= a + b) break; } while (j < num) { (*prentry)(base, j); loc += (*length)(base, j); z++; b += nrows; for (j++; j < num; j++) { c++; if (c >= a + b) break; } if (j < num) { while (loc < z * maxlen) { addch(' '); loc++; } } } getyx(stdscr, row, col); move(row + 1, 0); } refresh(); } static int get_maxlen(base, num, length) const char *const base[]; int num; int (*length)(const char *const *, int); { int i, len, max; max = (*length)(base, 0); for (i = 0; i < num; i++) { if ((len = (*length)(base, i)) > max) max = len; } return(max); } bsd-games-2.17/boggle/boggle/help.c0000664000175000017500000000600007767741711015606 0ustar jsm28jsm28/* $NetBSD: help.c,v 1.5 2003/08/07 09:37:05 agc Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)help.c 8.1 (Berkeley) 6/11/93"; #else __RCSID("$NetBSD: help.c,v 1.5 2003/08/07 09:37:05 agc Exp $"); #endif #endif /* not lint */ #include #include #include "bog.h" #include "extern.h" extern int nlines; int help() { int eof, i; FILE *fp; WINDOW *win; char buf[BUFSIZ]; if ((fp = fopen(HELPFILE, "r")) == NULL) return(-1); win = newwin(0, 0, 0, 0); clearok(win, 1); eof = 0; if (ungetc(getc(fp), fp) == EOF) { wprintw(win, "There doesn't seem to be any help."); eof = 1; /* Nothing there... */ } while (!eof) { for (i = 0; i < nlines - 3; i++) { if (fgets(buf, sizeof(buf), fp) == (char *) NULL) { eof = 1; break; } if (buf[0] == '.' && buf[1] == '\n') break; wprintw(win, "%s", buf); } if (eof || ungetc(getc(fp), fp) == EOF) { eof = 1; break; } wmove(win, nlines - 1, 0); wprintw(win, "Type to continue, anything else to quit..."); wrefresh(win); if ((inputch() & 0177) != ' ') break; wclear(win); } fclose(fp); if (eof) { wmove(win, nlines - 1, 0); wprintw(win, "Hit any key to continue..."); wrefresh(win); inputch(); } delwin(win); #ifdef NCURSES_VERSION redrawwin(stdscr); #else clearok(stdscr, 1); refresh(); #endif return(0); } bsd-games-2.17/boggle/boggle/mach.c0000664000175000017500000003035410155330535015556 0ustar jsm28jsm28/* $NetBSD: mach.c,v 1.14 2004/11/05 21:30:31 dsl Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)mach.c 8.1 (Berkeley) 6/11/93"; #else __RCSID("$NetBSD: mach.c,v 1.14 2004/11/05 21:30:31 dsl Exp $"); #endif #endif /* not lint */ /* * Terminal interface * * Input is raw and unechoed */ #include #include #include #include #include #include #include #include #include #include #include "bog.h" #include "extern.h" static int ccol, crow, maxw; static int colstarts[MAXCOLS], ncolstarts; static int lastline; int ncols, nlines; extern const char *pword[], *mword[]; extern int ngames, nmwords, npwords, tnmwords, tnpwords; extern char board[]; extern int usedbits, wordpath[]; extern time_t start_t; extern int debug; static void cont_catcher(int); static int prwidth(const char *const [], int); static void prword(const char *const [], int); static void stop_catcher(int); static void tty_cleanup(void); static int tty_setup(void); static void tty_showboard(const char *); static void winch_catcher(int); /* * Do system dependent initialization * This is called once, when the program starts */ int setup(sflag, seed) int sflag; time_t seed; { if (tty_setup() < 0) return(-1); if (!sflag) time(&seed); srandom(seed); if (debug) (void) printf("seed = %ld\n", (long) seed); return(0); } /* * Do system dependent clean up * This is called once, just before the program terminates */ void cleanup() { tty_cleanup(); } /* * Display the player's word list, the list of words not found, and the running * stats */ void results() { int col, row; int denom1, denom2; move(LIST_LINE, LIST_COL); clrtobot(); printw("Words you found (%d):", npwords); refresh(); move(LIST_LINE + 1, LIST_COL); prtable(pword, npwords, 0, ncols, prword, prwidth); getyx(stdscr, row, col); move(row + 1, col); printw("Words you missed (%d):", nmwords); refresh(); move(row + 2, col); prtable(mword, nmwords, 0, ncols, prword, prwidth); denom1 = npwords + nmwords; denom2 = tnpwords + tnmwords; move(SCORE_LINE, SCORE_COL); printw("Percentage: %0.2f%% (%0.2f%% over %d game%s)\n", denom1 ? (100.0 * npwords) / (double) (npwords + nmwords) : 0.0, denom2 ? (100.0 * tnpwords) / (double) (tnpwords + tnmwords) : 0.0, ngames, ngames > 1 ? "s" : ""); } static void prword(base, indx) const char *const base[]; int indx; { printw("%s", base[indx]); } static int prwidth(base, indx) const char *const base[]; int indx; { return (strlen(base[indx])); } /* * Main input routine * * - doesn't accept words longer than MAXWORDLEN or containing caps */ char * getline(q) char *q; { int ch, done; char *p; int row, col; p = q; done = 0; while (!done) { ch = timerch(); switch (ch) { case '\n': case '\r': case ' ': done = 1; break; case '\033': findword(); break; case '\177': /* */ case '\010': /* */ if (p == q) break; p--; getyx(stdscr, row, col); move(row, col - 1); clrtoeol(); refresh(); break; case '\025': /* <^u> */ case '\027': /* <^w> */ if (p == q) break; getyx(stdscr, row, col); move(row, col - (int) (p - q)); p = q; clrtoeol(); refresh(); break; #ifdef SIGTSTP case '\032': /* <^z> */ stop_catcher(0); break; #endif case '\023': /* <^s> */ stoptime(); printw(""); refresh(); while ((ch = inputch()) != '\021' && ch != '\023') ; move(crow, ccol); clrtoeol(); refresh(); starttime(); break; case '\003': /* <^c> */ cleanup(); exit(0); /*NOTREACHED*/ case '\004': /* <^d> */ done = 1; ch = EOF; break; case '\014': /* <^l> */ case '\022': /* <^r> */ redraw(); break; case '?': stoptime(); if (help() < 0) showstr("Can't open help file", 1); starttime(); break; default: if (!islower(ch)) break; if ((int) (p - q) == MAXWORDLEN) { p = q; badword(); break; } *p++ = ch; addch(ch); refresh(); break; } } *p = '\0'; if (ch == EOF) return((char *) NULL); return(q); } int inputch() { return (getch() & 0177); } void redraw() { clearok(stdscr, 1); refresh(); } void flushin(fp) FILE *fp; { (void) tcflush(fileno(fp), TCIFLUSH); } static int gone; /* * Stop the game timer */ void stoptime() { time_t t; (void)time(&t); gone = (int) (t - start_t); } /* * Restart the game timer */ void starttime() { time_t t; (void)time(&t); start_t = t - (long) gone; } /* * Initialize for the display of the player's words as they are typed * This display starts at (LIST_LINE, LIST_COL) and goes "down" until the last * line. After the last line a new column is started at LIST_LINE * Keep track of each column position for showword() * There is no check for exceeding COLS */ void startwords() { crow = LIST_LINE; ccol = LIST_COL; maxw = 0; ncolstarts = 1; colstarts[0] = LIST_COL; move(LIST_LINE, LIST_COL); refresh(); } /* * Add a word to the list and start a new column if necessary * The maximum width of the current column is maintained so we know where * to start the next column */ void addword(w) const char *w; { int n; if (crow == lastline) { crow = LIST_LINE; ccol += (maxw + 5); colstarts[ncolstarts++] = ccol; maxw = 0; move(crow, ccol); } else { move(++crow, ccol); if ((n = strlen(w)) > maxw) maxw = n; } refresh(); } /* * The current word is unacceptable so erase it */ void badword() { move(crow, ccol); clrtoeol(); refresh(); } /* * Highlight the nth word in the list (starting with word 0) * No check for wild arg */ void showword(n) int n; { int col, row; row = LIST_LINE + n % (lastline - LIST_LINE + 1); col = colstarts[n / (lastline - LIST_LINE + 1)]; move(row, col); standout(); printw("%s", pword[n]); standend(); move(crow, ccol); refresh(); delay(15); move(row, col); printw("%s", pword[n]); move(crow, ccol); refresh(); } /* * Get a word from the user and check if it is in either of the two * word lists * If it's found, show the word on the board for a short time and then * erase the word * * Note: this function knows about the format of the board */ void findword() { int c, col, found, i, r, row; char buf[MAXWORDLEN + 1]; getyx(stdscr, r, c); getword(buf); found = 0; for (i = 0; i < npwords; i++) { if (strcmp(buf, pword[i]) == 0) { found = 1; break; } } if (!found) { for (i = 0; i < nmwords; i++) { if (strcmp(buf, mword[i]) == 0) { found = 1; break; } } } for (i = 0; i < MAXWORDLEN; i++) wordpath[i] = -1; usedbits = 0; if (!found || checkword(buf, -1, wordpath) == -1) { move(r, c); clrtoeol(); addstr("[???]"); refresh(); delay(10); move(r, c); clrtoeol(); refresh(); return; } standout(); for (i = 0; wordpath[i] != -1; i++) { row = BOARD_LINE + (wordpath[i] / 4) * 2 + 1; col = BOARD_COL + (wordpath[i] % 4) * 4 + 2; move(row, col); if (board[wordpath[i]] == 'q') printw("Qu"); else printw("%c", toupper((unsigned char)board[wordpath[i]])); move(r, c); refresh(); delay(5); } standend(); for (i = 0; wordpath[i] != -1; i++) { row = BOARD_LINE + (wordpath[i] / 4) * 2 + 1; col = BOARD_COL + (wordpath[i] % 4) * 4 + 2; move(row, col); if (board[wordpath[i]] == 'q') printw("Qu"); else printw("%c", toupper((unsigned char)board[wordpath[i]])); } move(r, c); clrtoeol(); refresh(); } /* * Display a string at the current cursor position for the given number of secs */ void showstr(str, delaysecs) const char *str; int delaysecs; { addstr(str); refresh(); delay(delaysecs * 10); move(crow, ccol); clrtoeol(); refresh(); } void putstr(s) const char *s; { addstr(s); } /* * Get a valid word and put it in the buffer */ void getword(q) char *q; { int ch, col, done, i, row; char *p; done = 0; i = 0; p = q; addch('['); refresh(); while (!done && i < MAXWORDLEN - 1) { ch = getch() & 0177; switch (ch) { case '\177': /* */ case '\010': /* */ if (p == q) break; p--; getyx(stdscr, row, col); move(row, col - 1); clrtoeol(); break; case '\025': /* <^u> */ case '\027': /* <^w> */ if (p == q) break; getyx(stdscr, row, col); move(row, col - (int) (p - q)); p = q; clrtoeol(); break; case ' ': case '\n': case '\r': done = 1; break; case '\014': /* <^l> */ case '\022': /* <^r> */ clearok(stdscr, 1); refresh(); break; default: if (islower(ch)) { *p++ = ch; addch(ch); i++; } break; } refresh(); } *p = '\0'; addch(']'); refresh(); } void showboard(b) const char *b; { tty_showboard(b); } void prompt(mesg) const char *mesg; { move(PROMPT_LINE, PROMPT_COL); printw("%s", mesg); move(PROMPT_LINE + 1, PROMPT_COL); refresh(); } static int tty_setup() { initscr(); raw(); noecho(); /* * Does curses look at the winsize structure? * Should handle SIGWINCH ... */ nlines = LINES; lastline = nlines - 1; ncols = COLS; signal(SIGTSTP, stop_catcher); signal(SIGCONT, cont_catcher); signal(SIGWINCH, winch_catcher); return(0); } static void stop_catcher(signo) int signo __attribute__((__unused__)); { sigset_t sigset, osigset; stoptime(); noraw(); echo(); move(nlines - 1, 0); refresh(); signal(SIGTSTP, SIG_DFL); sigemptyset(&sigset); sigaddset(&sigset, SIGTSTP); sigprocmask(SIG_UNBLOCK, &sigset, &osigset); kill(0, SIGTSTP); sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); signal(SIGTSTP, stop_catcher); } static void cont_catcher(signo) int signo __attribute__((__unused__)); { noecho(); raw(); clearok(stdscr, 1); move(crow, ccol); refresh(); starttime(); } /* * The signal is caught but nothing is done about it... * It would mean reformatting the entire display */ static void winch_catcher(signo) int signo __attribute__((__unused__)); { /* struct winsize win; */ (void) signal(SIGWINCH, winch_catcher); /* (void) ioctl(fileno(stdout), TIOCGWINSZ, &win); LINES = win.ws_row; COLS = win.ws_col; */ } static void tty_cleanup() { move(nlines - 1, 0); refresh(); noraw(); echo(); endwin(); } static void tty_showboard(b) const char *b; { int i; int line; clear(); move(BOARD_LINE, BOARD_COL); line = BOARD_LINE; printw("+---+---+---+---+"); move(++line, BOARD_COL); for (i = 0; i < 16; i++) { if (b[i] == 'q') printw("| Qu"); else printw("| %c ", toupper((unsigned char)b[i])); if ((i + 1) % 4 == 0) { printw("|"); move(++line, BOARD_COL); printw("+---+---+---+---+"); move(++line, BOARD_COL); } } move(SCORE_LINE, SCORE_COL); printw("Type '?' for help"); refresh(); } bsd-games-2.17/boggle/boggle/extern.h0000664000175000017500000000523610005547567016172 0ustar jsm28jsm28/* $NetBSD: extern.h,v 1.8 2004/01/27 20:30:29 jsm Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/11/93 */ #include void addword(const char *); void badword(void); char *batchword(FILE *); void checkdict(void); int checkword(const char *, int, int *); void cleanup(void); void delay(int); long dictseek(FILE *, long, int); void findword(void); void flushin(FILE *); char *getline(char *); void getword(char *); int help(void); int inputch(void); int loaddict(FILE *); int loadindex(const char *); void newgame(const char *); char *nextword(FILE *); FILE *opendict(const char *); void playgame(void); void prompt(const char *); void prtable(const char *const [], int, int, int, void (*)(const char *const [], int), int (*)(const char *const [], int)); void putstr(const char *); void redraw(void); void results(void); int setup(int, time_t); void showboard(const char *); void showstr(const char *, int); void showword(int); void starttime(void); void startwords(void); void stoptime(void); int timerch(void); void usage(void) __attribute__((__noreturn__)); int validword(const char *); bsd-games-2.17/boggle/boggle/word.c0000664000175000017500000001163007767741711015636 0ustar jsm28jsm28/* $NetBSD: word.c,v 1.7 2003/08/07 09:37:06 agc Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)word.c 8.1 (Berkeley) 6/11/93"; #else __RCSID("$NetBSD: word.c,v 1.7 2003/08/07 09:37:06 agc Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include "bog.h" #include "extern.h" static char *dictspace, *dictend; static char *sp; static int first = 1, lastch = 0; extern struct dictindex dictindex[]; extern int wordlen; /* * Return the next word in the compressed dictionary in 'buffer' or * NULL on end-of-file */ char * nextword(fp) FILE *fp; { int ch, pcount; char *p; static char buf[MAXWORDLEN + 1]; if (fp == NULL) { if (sp == dictend) return (NULL); p = buf + (int) *sp++; /* * The dictionary ends with a null byte */ while (*sp >= 'a') if ((*p++ = *sp++) == 'q') *p++ = 'u'; } else { if (first) { if ((pcount = getc(fp)) == EOF) return (NULL); first = 0; } else if ((pcount = lastch) == EOF) return (NULL); p = buf + pcount; while ((ch = getc(fp)) != EOF && ch >= 'a') if ((*p++ = ch) == 'q') *p++ = 'u'; lastch = ch; } wordlen = (int) (p - buf); *p = '\0'; return (buf); } /* * Reset the state of nextword() and do the fseek() */ long dictseek(fp, offset, ptrname) FILE *fp; long offset; int ptrname; { if (fp == NULL) { if ((sp = dictspace + offset) >= dictend) return (-1); return (0); } first = 1; return (fseek(fp, offset, ptrname)); } FILE * opendict(dict) const char *dict; { FILE *fp; if ((fp = fopen(dict, "r")) == NULL) return (NULL); return (fp); } /* * Load the given dictionary and initialize the pointers */ int loaddict(fp) FILE *fp; { struct stat statb; long n; int st; char *p; if (fstat(fileno(fp), &statb) < 0) { (void)fclose(fp); return (-1); } /* * An extra character (a sentinel) is allocated and set to null * to improve the expansion loop in nextword(). */ if ((dictspace = malloc(statb.st_size + 1)) == NULL) { (void)fclose(fp); return (-1); } n = (long)statb.st_size; sp = dictspace; dictend = dictspace + n; p = dictspace; st = -1; while (n > 0 && (st = fread(p, 1, BUFSIZ, fp)) > 0) { p += st; n -= st; } if (st < 0) { (void)fclose(fp); warnx("Error reading dictionary"); return (-1); } *p = '\0'; return (0); } /* * Dependent on the exact format of the index file: * Starting offset field begins in column 1 and length field in column 9 * Taking the easy way out, the input buffer is made "large" and a check * is made for lines that are too long */ int loadindex(indexfile) const char *indexfile; { int i, j; char buf[BUFSIZ]; FILE *fp; if ((fp = fopen(indexfile, "r")) == NULL) { warn("Can't open '%s'", indexfile); return (-1); } i = 0; while (fgets(buf, sizeof(buf), fp) != NULL) { if (strchr(buf, '\n') == NULL) { warnx("A line in the index file is too long"); return(-1); } j = *buf - 'a'; if (i != j) { warnx("Bad index order"); return(-1); } dictindex[j].start = atol(buf + 1); dictindex[j].length = atol(buf + 9) - dictindex[j].start; i++; } if (i != 26) { warnx("Bad index length"); return(-1); } (void) fclose(fp); return(0); } bsd-games-2.17/boggle/boggle/Makefrag0000664000175000017500000000405606773402557016161 0ustar jsm28jsm28# Makefrag - makefile fragment for boggle/boggle # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # Defining NEW_STYLE causes this program to be compiled with the Linux # improvements; removing this definition gives the original BSD behaviour. # boggle_boggle_DEFS := -DNEW_STYLE boggle_boggle_DIRS := $(GAMESDIR) $(MAN6DIR) $(BOGGLE_DIR) boggle_boggle_all: boggle/boggle/boggle boggle/boggle/boggle.6 boggle/boggle/helpfile boggle_boggle_install: boggle_boggle_all $(INSTALL_BINARY) boggle/boggle/boggle $(INSTALL_PREFIX)$(GAMESDIR)/boggle $(HIDE_GAME) boggle $(INSTALL_MANUAL) boggle/boggle/boggle.6 $(INSTALL_DATA) boggle/boggle/helpfile $(INSTALL_PREFIX)$(BOGGLE_DIR)/helpfile bsd-games-2.17/boggle/mkindex/0000775000175000017500000000000010205246605014675 5ustar jsm28jsm28bsd-games-2.17/boggle/mkindex/Makefile.bsd0000664000175000017500000000031207641024615017105 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.10 2002/09/18 06:16:40 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 NOMAN= # defined HOSTPROG= mkindex HOST_CPPFLAGS+= -I${.CURDIR}/../boggle .include bsd-games-2.17/boggle/mkindex/mkindex.c0000664000175000017500000000755007767741711016530 0ustar jsm28jsm28/* $NetBSD: mkindex.c,v 1.9 2003/08/07 09:37:06 agc Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char copyright[] __attribute__((__unused__)) = "@(#) Copyright (c) 1993\n\ The Regents of the University of California. All rights reserved.\n"; #if 0 static char sccsid[] = "@(#)mkindex.c 8.1 (Berkeley) 6/11/93"; #else static const char rcsid[] __attribute__((__unused__)) = "$NetBSD: mkindex.c,v 1.9 2003/08/07 09:37:06 agc Exp $"; #endif #endif /* not lint */ #include #include #include "bog.h" int main(void); char *nextword(FILE *, char *, int *, int *); int main(void) { int clen, rlen, prev, i; long off, start; char buf[MAXWORDLEN + 1]; prev = '\0'; off = start = 0L; while (nextword(stdin, buf, &clen, &rlen) != NULL) { if (*buf != prev) { /* * Boggle expects a full index even if the dictionary * had no words beginning with some letters. * So we write out entries for every letter from prev * to *buf. */ if (prev != '\0') printf("%c %6ld %6ld\n", prev, start, off - 1); for (i = (prev ? prev + 1 : 'a'); i < *buf; i++) printf("%c %6ld %6ld\n", i, off, off - 1); prev = *buf; start = off; } off += clen + 1; } printf("%c %6ld %6ld\n", prev, start, off - 1); for (i = prev + 1; i <= 'z'; i++) printf("%c %6ld %6ld\n", i, off, off - 1); fflush(stdout); if (ferror(stdout)) { perror("error writing standard output"); exit(1); } exit(0); } /* * Return the next word in the compressed dictionary in 'buffer' or * NULL on end-of-file * Also set clen to the length of the compressed word (for mkindex) and * rlen to the strlen() of the real word */ char * nextword(fp, buffer, clen, rlen) FILE *fp; char *buffer; int *clen, *rlen; { int ch, pcount; char *p, *q; static char buf[MAXWORDLEN + 1]; static int first = 1; static int lastch = 0; if (first) { if ((pcount = getc(fp)) == EOF) return (NULL); first = 0; } else if ((pcount = lastch) == EOF) return (NULL); p = buf + (*clen = pcount); while ((ch = getc(fp)) != EOF && ch >= 'a') *p++ = ch; lastch = ch; *p = '\0'; *rlen = (int) (p - buf); *clen = *rlen - *clen; p = buf; q = buffer; while ((*q++ = *p) != '\0') { if (*p++ == 'q') *q++ = 'u'; } return (buffer); } bsd-games-2.17/boggle/mkindex/Makefrag0000664000175000017500000000355706773402557016366 0ustar jsm28jsm28# Makefrag - makefile fragment for boggle/mkindex # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. boggle_mkindex_CLEANFILES := dictindex boggle_mkindex_DIRS := $(BOGGLE_DIR) boggle_mkindex_INCS := -Iboggle/boggle boggle/mkindex/dictindex: boggle/mkindex/mkindex boggle/mkdict/dictionary $< $@ boggle_mkindex_all: boggle/mkindex/dictindex boggle_mkindex_install: boggle_mkindex_all $(INSTALL_DATA) boggle/mkindex/dictindex $(INSTALL_PREFIX)$(BOGGLE_DIR)/dictindex bsd-games-2.17/boggle/mkdict/0000775000175000017500000000000010205246605014511 5ustar jsm28jsm28bsd-games-2.17/boggle/mkdict/Makefile.bsd0000664000175000017500000000031107641024615016720 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.12 2002/09/18 06:16:40 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 NOMAN= # defined HOSTPROG= mkdict HOST_CPPFLAGS+= -I${.CURDIR}/../boggle .include bsd-games-2.17/boggle/mkdict/mkdict.c0000664000175000017500000000725007767741711016155 0ustar jsm28jsm28/* $NetBSD: mkdict.c,v 1.9 2003/08/07 09:37:06 agc Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Barry Brachman. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char copyright[] __attribute__((__unused__)) = "@(#) Copyright (c) 1993\n\ The Regents of the University of California. All rights reserved.\n"; #if 0 static char sccsid[] = "@(#)mkdict.c 8.1 (Berkeley) 6/11/93"; #else static const char rcsid[] __attribute__((__unused__)) = "$NetBSD: mkdict.c,v 1.9 2003/08/07 09:37:06 agc Exp $"; #endif #endif /* not lint */ /* * Filter out words that: * 1) Are not completely made up of lower case letters * 2) Contain a 'q' not immediately followed by a 'u' * 3) Are less that 3 characters long * 4) Are greater than MAXWORDLEN characters long */ #include #include #include #include #include "bog.h" int main(int, char *[]); int main(argc, argv) int argc; char *argv[]; { char *p, *q; int ch, common, nwords; int current, len, prev, qcount; char buf[2][MAXWORDLEN + 1]; prev = 0; current = 1; buf[prev][0] = '\0'; for (nwords = 1; fgets(buf[current], MAXWORDLEN + 1, stdin) != NULL; ++nwords) { if ((p = strchr(buf[current], '\n')) == NULL) { fprintf(stderr, "word too long: %s\n", buf[current]); while ((ch = getc(stdin)) != EOF && ch != '\n') ; if (ch == EOF) break; continue; } len = 0; for (p = buf[current]; *p != '\n'; p++) { if (!islower(*p)) break; if (*p == 'q') { q = p + 1; if (*q != 'u') break; else { while ((*q = *(q + 1))) q++; } len++; } len++; } if (*p != '\n' || len < 3 || len > MAXWORDLEN) continue; if (argc == 2 && nwords % atoi(argv[1])) continue; *p = '\0'; p = buf[current]; q = buf[prev]; qcount = 0; while ((ch = *p++) == *q++ && ch != '\0') if (ch == 'q') qcount++; common = p - buf[current] - 1; printf("%c%s", common + qcount, p - 1); prev = !prev; current = !current; } fprintf(stderr, "%d words\n", nwords); fflush(stdout); if (ferror(stdout)) { perror("error writing standard output"); exit(1); } exit(0); } bsd-games-2.17/boggle/mkdict/Makefrag0000664000175000017500000000400406773402557016166 0ustar jsm28jsm28# Makefrag - makefile fragment for boggle/mkdict # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. boggle_mkdict_CLEANFILES := dictionary # boggle_mkdict_DICTSRC is the dictionary that will be used to construct the # word list used by boggle. boggle_mkdict_DICTSRC := $(DICTIONARY_SRC) boggle_mkdict_DIRS := $(BOGGLE_DIR) boggle_mkdict_INCS := -Iboggle/boggle boggle/mkdict/dictionary: boggle/mkdict/mkdict $(boggle_mkdict_DICTSRC) $< <$(boggle_mkdict_DICTSRC) >$@ boggle_mkdict_all: boggle/mkdict/dictionary boggle_mkdict_install: boggle_mkdict_all $(INSTALL_DATA) boggle/mkdict/dictionary $(INSTALL_PREFIX)$(BOGGLE_DIR)/dictionary bsd-games-2.17/boggle/Makefrag0000664000175000017500000000276106773402557014723 0ustar jsm28jsm28# Makefrag - makefile fragment for boggle # # Copyright (c) 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. boggle_all: boggle_install: bsd-games-2.17/boggle/Makefile.bsd0000664000175000017500000000154007767741711015466 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.22 2003/10/21 10:01:19 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 .include SUBDIR= boggle mkdict mkindex MKDICTDIR!= cd $(.CURDIR)/mkdict; ${PRINTOBJDIR} MKDICT=${MKDICTDIR}/mkdict MKINDEXDIR!= cd $(.CURDIR)/mkindex; ${PRINTOBJDIR} MKINDEX=${MKINDEXDIR}/mkindex WORDS=${NETBSDSRCDIR}/share/dict/web2 DICTFILES=dictionary dictindex .if ${MKSHARE} != "no" FILES=${DICTFILES} FILESDIR=/usr/share/games/boggle .endif CLEANFILES+=${DICTFILES} realall: ${FILES} ${MKDICT}: @cd ${.CURDIR}/mkdict && ${MAKE} ${MKINDEX}: @cd ${.CURDIR}/mkindex && ${MAKE} dictionary: ${WORDS} ${MKDICT} ${_MKTARGET_CREATE} rm -f ${.TARGET} ${MKDICT} < ${WORDS} > ${.TARGET} dictindex: dictionary ${MKINDEX} ${_MKTARGET_CREATE} rm -f ${.TARGET} ${MKINDEX} < dictionary > ${.TARGET} .include .include bsd-games-2.17/boggle/README0000664000175000017500000000446306602512212014121 0ustar jsm28jsm28$NetBSD: README,v 1.2 1995/03/21 12:14:21 cgd Exp $ Bog is a fairly portable simulation of Parker Brother's game of Boggle and is similar to the 4.[23] BSD "boggle" and Sun's "boggletool". Bog has not been derived from any proprietary code. It has been tested on the Sun 3 under SunOS 3.2 and on the Atari 1040ST (MWC). What You Need You will need curses/termcap and a large word list. The minix word list or /usr/dict/words will do nicely. The word list must already be sorted (you can use "sort -c" to check). Contents README - this file Makefile bog.man - half-hearted man page (use the game's help command) bog.h - configuration and header info bog.c - machine independent game code word.c - machine independent word list routines help.c - (curses) help routine mach.c - (curses) display code prtable.c - ditto timer.c - machine dependent (os) input polling mkdict.c - convert a word list to a bog dictionary mkindex.c - create an index file for the bog dictionary showdict.c - print a bog dictionary to stdout Portability - I've tried to make bog.c (the program logic) independent of the I/O. My plan was to make it straightforward to adapt the game to run under a windowing system (eg., Suntools, GEM). I have no plan to actually do this. I've stuck to a small subset of the curses routines. - The program runs with the input in raw mode. - If you want the running timer you must #define TIMER in bog.h and insert the input polling code in timer.c for your system. There is already code there for BSD, SYSV, and ATARI. Setup 1. Check bog.h and Makefile and edit to fit your environment 2. "make all" This will make all the binaries and create the dictionary and index files 3. Move "dict", "dict.ind", and "helpfile" to where you specified in bog.h 4. Play away Enjoy. [But beware: boggle can be addictive!] ----- Barry Brachman | UUCP: {alberta,uw-beaver,uunet}! Dept. of Computer Science| ubc-vision!ubc-csgrads!brachman Univ. of British Columbia| Internet: brachman@cs.ubc.ca Vancouver, B.C. V6T 1W5 | brachman%ubc.csnet@csnet-relay.arpa (604) 228-5010 | brachman@ubc.csnet Note: Barry Brachman has confirmed that boggle is under the standard BSD licence, and he is no longer supporting the game, so bug reports should go to the appropriate distributor. bsd-games-2.17/bsd-games.lsm0000664000175000017500000000150710205245257014363 0ustar jsm28jsm28Begin4 Title: bsd-games Version: 2.17 Entered-date: 2005-02-18 Description: Port of most of the games from NetBSD-current. Games included: adventure arithmetic atc backgammon banner battlestar bcd boggle caesar canfield countmail cribbage dab dm factor fish fortune gomoku hack hangman hunt mille monop morse number phantasia pig pom ppt primes quiz rain random robots sail snake tetris trek wargames worm worms wtf wump. Keywords: games, NetBSD Maintained-by: jsm@polyomino.org.uk (Joseph S. Myers) Primary-site: ibiblio.org /pub/Linux/games bsd-games-2.17.tar.gz Alternate-site: tsx-11.mit.edu /pub/linux/sources/usr.games Original-site: ftp.netbsd.org /pub/NetBSD/NetBSD-current/tar_files/src games.tar.gz Platforms: Requires ncurses (curses/termcap may also work but are no longer tested/supported) Copying-policy: BSD End bsd-games-2.17/wtf/0000775000175000017500000000000010205246606012600 5ustar jsm28jsm28bsd-games-2.17/wtf/acronyms.comp0000664000175000017500000002346210205244002015306 0ustar jsm28jsm28$NetBSD: acronyms.comp,v 1.58 2005/02/16 00:04:23 kleink Exp $ 3WHS three-way handshake ABI application binary interface ACL access control list ACPI advanced configuration and power interface ADC analog [to] digital converter ADPCM adaptive differential pulse code modulation ADSL asymmetric digital subscriber line AGP accelerated graphics port AM amplitude modulation AMI alternate mark inversion ANSI american national standards institute AP access point API application programming interface APIC advanced programmable interrupt controller ARP address resolution protocol ARQ automatic repeat request AS autonomous system ASN autonomous system number ASCII american standard code for information interchange AT advanced technology ATA advanced technology attachment ATAPI advanced technology attachment packet interface ATM asynchronous transfer mode ATX advanced technology extended BEDO burst extended data output BER basic encoding rules BER bit error rate BGP border gateway protocol BIOS basic input/output system BLOB binary large object BPS bits per second BSD berkeley software distribution CAD computer-aided design CAV constant angular velocity (as opposed to CLV) CCD charge coupled device CD compact disc CDDA compact disc digital audio CDRAM cache dynamic random access memory CER canonical encoding rules CGA color graphics array CGI common gateway interface CHS cylinder/head/sector CIDR classless inter-domain routing CIS contact image sensor CLI command line interface CLV constant linear velocity (as opposed to CAV) CMYK cyan magenta yellow black COFF common object file format COW copy-on-write CPU central processing unit CRLF carriage return line feed CRT cathode ray tube CSMA carrier sense multiple access CSMA/CA carrier sense multiple access with collision avoidance CSMA/CD carrier sense multiple access with collision detection CSS cascading style sheets CTS clear to send CVS concurrent versions system DAC digital [to] analog converter DCE data control equipment DCE distributed computing environment DCT discrete cosine transform DDC display data channel DDR double data rate DDWG digital display working group DER distinguished encoding rules DFT discrete fourier transform DHCP dynamic host configuration protocol DIFS distributed inter-frame space DLE data link escape DMA direct memory access DNS domain name system DOS denial of service DPCM differential pulse code modulation DPI dots per inch DRAM dynamic random access memory DSL digital subscriber line DSSS direct sequence spread spectrum DTD document type definition DTE data terminal equipment DTE dumb terminal emulator DVD digital versatile disc DVI digital visual interface ECP enhanced capability port EDID extended display identification data EDO extended data out EEPROM electrically erasable programmable read only memory EFM eight to fourteen modulation EGA enhanced graphics array EGP exterior gateway protocol EISA extended industry standard architecture ELF executable and linking format EPP enhanced parallel port EPRML extended partial response, maximum likelihood EPROM erasable programmable read only memory ESDRAM enhanced synchronous dynamic random access memory E-XER extended XML encoding rules FAT file allocation table FBRAM frame buffer random access memory FCS frame check sequence FDDI fiber distributed data interface FFS fast file system FHSS frequency hop spread spectrum FIR fast infrared FLOPS floating [point] operations per second FM frequency modulation FPM fast page mode FQDN fully qualified domain name FTP file transfer protocol GC garbage collector GCR group-coded recording GIF graphics interchange format GNU gnu's not unix GPL gnu/general public license GPU graphics processing unit GRE generic routing encapsulation GUI graphics user interface HDCP high-bandwidth digital content protection HTML hyper-text markup language HTTP hyper-text transfer protocol I2O intelligent input/output IANA internet assigned number authority IC integrated circuit ICB internet citizen's band ICMP internet control message protocol IDE integrated drive electronics IDRP inter-domain routing protocol IEC international electrotechnical commission IEEE institute [of] electrical [and] electronics engineers IESG internet engineering steering group IETF internet engineering task force IGP interior gateway protocol IKE internet key exchange IMAP internet mail access protocol INCITS international committee on information technology standards IPC interprocess communication IO input/output IOCTL input/output control IP internet protocol IPNG internet protocol, next generation IPSEC internet protocol security IRC internet relay chat IRQ interrupt request IRTF internet research task force ISA industry standard architecture ISDN integrated services digital network ISI inter-symbol interference ISM industrial, scientific and medical ISN initial serial number ISO international standards organization ISOC internet society ISP internet service provider JPEG joint photographic experts group KVA kernel virtual address LAN local area network LBA logical block addressing LCD liquid crystal display LCP link control protocol LDAP lightweight directory access protocol LED light emitting diode LIR local internet registry LLC logical link control LRC longitudinal redundancy check LSB least significant bit [or: byte] LUN logical unit number LZW Lempel Ziv Welch MAC medium access control MBR master boot record MDRAM multibank dynamic random access memory MFM modified frequency modulation MIDI musical instrument digital interface MIME multipurpose internet mail extensions MIPS million instructions per second MMU memory management unit MPEG moving picture experts group MSB most significant bit [or: byte] MSF minutes seconds frames MSS maximum segment size MTA mail transfer agent MTU maximum transmission unit MUA mail user agent MWE module width encoding NAT network address translation NAV network allocation vector NCP network control protocol NFS network file system NIC network interface card NIS network information service NRZ non-return to zero NUMA non uniform memory access OCL object constraint language OCR optical character recognition OEM original equipment manufacturer OFDM orthogonal frequency division multiplexing OSF open software foundation OSI open systems interconnection OTP one time password PAM pluggable authentication modules PAM pulse amplitude modulation PAT port address translation PAX portable archive exchange PC personal computer PCI peripheral component interconnect PCM pulse code modulation PCMCIA personal computer memory card international association PDU protocol data unit PDP page descriptor page PER packed encoding rules PERL practical extraction [and] report language PGP pretty good privacy PIC programmable interrupt controller PID process id PIN personal identification number PIO programmed input/output PLL phase locked loop PMT photo-multiplier tube PNG portable network graphics POP post office protocol POSIX portable operating system interface [for] unix POST power on self test POTS plain old telephone system PPP point-to-point protocol PPPOA point-to-point protocol over ATM PPPOE point-to-point protocol over ethernet PRML partial response, maximum likelihood PROM programmable read only memory PTE page table entry PTLA pseudo top level aggregator PTP page table page PSTN public switched telephone network PWM pulse width modulation QOS quality of service RAID redundant array of inexpensive disks RAM random access memory RCS revision control system RFC request for comments RGB red green blue RIP routing information protocol RIR regional internet registry RISC reduced instruction set computing RLE run length encoding RLL run length limited ROM read only memory RPM revolutions per minute RTF rich text format RTS request to send RTT round time trip S/PDIF sony/phillips digital interface SACD super audio compact disc SAM serial access memory SASI shugart associates system interface (predecessor to SCSI) SATA serial advanced technology attachment SCSI small computer system interface SDRAM synchronous dynamic random access memory SGRAM synchronous graphics random access memory SIFS short inter-frame space SIP session initiation protocol SIR slow infrared SLDRAM synchronous-link dynamic random access memory SMART self-monitoring analysis and reporting technology SMP symmetric multiprocessing SMTP simple mail transfer protocol SNMP simple network management protocol SPD serial presence detect SRAM static random access memory SSFDC solid state floppy disc card SSH secure shell SSL secure sockets layer STP shielded twisted pair SVGA super video graphics array TCL tool command language TCP transmission control protocol TDD test driven development TFT thin film transistor TIFF tagged image file format TLA top level aggregator TLB transition lookaside buffer TLD top level domain TMDS transition minimized differential signaling TR token ring TTL time to live TTY teletype TZ time zone UART universal asynchronous receiver/transmitter UC uncacheable UDO ultra density optical (storage) UDP user datagram protocol UFS unix file system UML unified modeling language UPS uninterruptible power supply URI uniform resource identifier URL uniform resource locator USART universal synchronous/asynchronous receiver/transmitter USB universal serial bus USWC uncacheable speculative write combining UTP unshielded twisted pair UUCP unix-to-unix copy protocol VAX virtual address extension VCM virtual channel memory VESA video electronics standards association VGA video graphics array VLAN virtual local area network VLSM variable length subnetting mask VM virtual memory VPN virtual private network VRAM video random access memory WAN wide area network WAP wireless application protocol WLAN wireless local area network WRAM window random access memory WWW world wide web XER XML encoding rules XGA extended graphics array XML extensible markup language XSL extensible stylesheet language XT extended technology ZFOD zero-filled on demand bsd-games-2.17/wtf/Makefile.bsd0000664000175000017500000000020106767673067015027 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.1 1999/07/22 01:03:20 mrg Exp $ SCRIPTS= wtf SCRIPTSDIR= /usr/games MAN= wtf.6 .include bsd-games-2.17/wtf/wtf.in0000775000175000017500000000207507767741711013757 0ustar jsm28jsm28#!/bin/sh # # $NetBSD: wtf,v 1.11 2003/04/25 19:08:31 jmmv Exp $ # # Public domain # usage() { echo "usage: `basename $0` [-f dbfile] [-t type] [is] " exit 1 } acronyms=${ACRONYMDB:-@wtf_acronymfile@} args=`getopt f:t: $*` if [ $? -ne 0 ]; then usage fi set -- $args while [ $# -gt 0 ]; do case "$1" in -f) acronyms=$2; shift ;; -t) acronyms=@wtf_acronymfile@.$2; shift ;; --) shift; break ;; esac shift done if [ X"$1" = X"is" ] ; then shift fi if [ $# -lt 1 ] ; then usage fi if [ ! -f $acronyms ]; then echo "`basename $0`: cannot open acronyms database file \`$acronyms'" exit 1 fi rv=0 while [ $# -gt 0 ] ; do target=`echo $1 | tr '[a-z]' '[A-Z]'` ans=`fgrep $target < $acronyms 2>/dev/null \ | sed -ne "\|^$target[[:space:]]|s|^$target[[:space:]]*||p"` if [ "$ans" != "" ] ; then echo "$target: $ans" else ans=`whatis $1 2> /dev/null | egrep "^$1[, ]" 2> /dev/null` if [ $? -eq 0 ] ; then echo "$1: $ans" else echo "Gee... I don't know what $1 means..." 1>&2 rv=1 fi fi shift done exit $rv bsd-games-2.17/wtf/wtf.6.in0000664000175000017500000000257007767741711014120 0ustar jsm28jsm28.\" $NetBSD: wtf.6,v 1.8 2003/04/25 19:08:31 jmmv Exp $ .\" .\" Public Domain .\" .Dd April 25, 2003 .Dt WTF 6 .Os .Sh NAME .Nm wtf .Nd translates acronyms for you .Sh SYNOPSIS .Nm .Op Fl f Ar dbfile .Op Fl t Ar type .Op Ar is .Ar acronym Ar ... .Sh DESCRIPTION The .Nm utility displays the expansion of the acronyms specified on the command line. If the acronym is unknown, .Nm will check to see if the acronym is known by the .Xr whatis 1 command. .Pp If .Dq is is specified on the command line, it will be ignored, allowing the fairly natural .Dq wtf is WTF usage. .Pp The following options are available: .Bl -tag -width flag .It Fl f Ar dbfile Overrides the default acronym database, bypassing the value of the .Ev ACRONYMDB variable. .It Fl t Ar type Specifies the acronym's type. Simply put, it makes the program use the acronyms database named .Pa @wtf_acronymfile@.type , where .Ar type is given by the argument. .El .Sh ENVIRONMENT .Bl -tag -width ACRONYMDB .It Ev ACRONYMDB The default acronym database may be overridden by setting the environment variable .Ev ACRONYMDB to the name of a file in the proper format (acronym[tab]meaning). .El .Sh FILES .Bl -tag -width @wtf_acronymfile@.XXXX -compact .It Pa @wtf_acronymfile@ default acronym database. .It Pa @wtf_acronymfile@.comp computer-related acronym database. .El .Sh SEE ALSO .Xr whatis 1 .Sh HISTORY .Nm first appeared in .Nx 1.5 . bsd-games-2.17/wtf/acronyms0000664000175000017500000001424010205244002014343 0ustar jsm28jsm28$NetBSD: acronyms,v 1.145 2005/02/18 01:40:49 jsm Exp $ AFAIC as far as I'm concerned AFAICR as far as I can recall AFAICT as far as I can tell AFAIK as far as I know AFAIR as far as I recall AFAIU as far as I understand AFD away from desktop AFK away from keyboard AFU all fucked up AFW away from window AIU as I understand AIUI as I understand it AKA also known as ASAIC as soon as I can ASAP as soon as possible ATM at the moment AWOL absent without official leave AYBABTU all your base are belong to us AYT are you there B/C because B/S bullshit B/W between BBIAB be back in a bit BBL [I'll] be back later BBS be back soon BBT be back tomorrow BFD big fucking deal BIAB back in a bit BIAF back in a few BIALW back in a little while BIAS back in a second BIAW back in a while BOATILAS bend over and take it like a slut BOFH bastard operator from hell BOGAHICA bend over, grab ankles, here it comes again BOHICA bend over here it comes again BRB [I'll] be right back BS bullshit BTDT been there, done that BTTH boot to the head BTW by the way CMIIW correct me if I'm wrong CNP continued [in my] next post COB close of business [day] COTS commercial off-the-shelf CYA see you around D/L download DIY do it yourself DKDC don't know, don't care DSTM don't shoot the messenger DTRT do the right thing DTWT do the wrong thing DWIM do what I mean EG evil grin EMSG email message EOB end of business [day] EOD end of discussion EOL end of life ETLA extended three letter acronym EWAG experienced wild-ass guess FAQ frequently asked question FCFS first come first served FIGJAM fuck I'm good, just ask me FIIK fuck[ed] if I know FIIR fuck[ed] if I remember FM fucking magic FOAD fall over and die FSDO for some definition of FSVO for some value of FTFM fuck the fuckin' manual! FUBAR fucked up beyond all recognition FUD fear, uncertainty and doubt FWIW for what it's worth FYI for your information G grin G/C garbage collect GAC get a clue GAL get a life GIGO garbage in, garbage out GMTA great minds think alike GTFO get the fuck out GTG got to go HAND have a nice day HHIS hanging head in shame HICA here it comes again HTH hope this helps IAC in any case IANAL I am not a lawyer IC I see ICBW I could be wrong ICCL I couldn't care less IHAFC I haven't a fucking clue IHBW I have been wrong IHNFC I have no fucking clue IIANM if I am not mistaken IIRC if I recall correctly IIUC if I understand correctly IMAO in my arrogant opinion IMCO in my considered opinion IMHO in my humble opinion IMNSHO in my not so humble opinion IMO in my opinion IOW in other words IRL in real life ISAGN I see a great need ISTM it seems to me ISTR I seem to recall ITYM I think you mean IWBNI it would be nice if IYSS if you say so J/K just kidding JHD just hit ``delete'' JIC just in case JK just kidding JMO just my opinion JTLYK just to let you know KISS keep it simple, stupid KITA kick in the ass KNF kernel normal form L8R later LART luser attitude readjustment tool (ie, hammer) LBNL last but not least LJBF let's just be friends LMAO laughing my ass off LMSO laughing my socks off LOL laughing out loud LTNS long time no see MIA missing in action MOTAS member of the appropriate sex MOTOS member of the opposite sex MOTSS member of the same sex MTF more to follow MYOB mind your own business N/M never mind NBD no big deal NFC no fucking clue NFI no fucking idea NFW no fucking way NIH not invented here NMF not my fault NMP not my problem NOYB none of your business NOYFB none of your fucking business NP no problem NRFPT not ready for prime time NRN no reply necessary OIC oh, I see OMG oh, my god OT off topic OTL out to lunch OTOH on the other hand OTT over the top OTTOMH off the top of my head PEBKAC problem exists between keyboard and chair PFO please fuck off PFY pimply faced youth PITA pain in the ass PKSP pound keys and spew profanity PNG persona non grata PNP plug and pray POC point of contact POLA principle of least astonishment POLS principle of least surprise POS piece of shit PPL pretty please PTV parental tunnel vision QED quod erat demonstrandum RFC request for comments RIP rest in peace RL real life RLC rod length check ROFL rolling on floor laughing ROFLMAO rolling on floor laughing my ass off ROTFL rolling on the floor laughing RP responsible person RSN real soon now RTFB read the fine/fucking book RTFC read the fine/fucking code RTFD read the fine/fucking documentation RTFM read the fine/fucking manual RTFMP read the fine/fucking man page RTFS read the fine/fucking source SCNR sorry, could not resist SEP someone else's problem SFA sweet fuck all SHID slaps head in disgust SIMCA sitting in my chair amused SMLSFB so many losers, so few bullets SMOP simple matter of programming SNAFU situation normal, all fucked up SNERT snot-nosed egotistical rude teenager SNMP sorry, not my problem SNR signal to noise ratio SO significant other SOB son of [a] bitch SOL shit out [of] luck SOP standard operating procedure SSIA subject says it all STFA search the fucking archives STFU shut the fuck up STFW search the fucking web SUS stupid user syndrome SWAG silly, wild-assed guess SWAHBI silly, wild-assed hare-brained idea SWMBO she who must be obeyed TANSTAAFL there ain't no such thing as a free lunch TBC to be continued TBD to be {decided,determined,done} TBOMK the best of my knowledge THNX thanks THX thanks TIA thanks in advance TINC there is no cabal TLA three letter acronym TLB translation lookaside buffer TMA too many abbreviations TMI too much information TNF The NetBSD Foundation TOEFL test of english as a foreign language TPTB the powers that be TRT the right thing TTBOMK to the best of my knowledge TTFN ta ta for now TTYL talk to you later TWIAVBP the world is a very big place TY thank you TYVM thank you very much U/L upload UTSL use the source, Luke VEG very evil grin W/ with W/O without WAG wild-ass guess WB welcome back WFM works for me WIBNI wouldn't it be nice if WIP work in progress WOFTAM waste of fucking time and money WOMBAT waste of money, brain, and time WRT with respect to WTF {what,where,who,why} the fuck WTH {what,where,who,why} the hell WYSIWYG what you see is what you get YALIMO you are lame, in my opinion YHBT you have been trolled YHL you have lost YKWIM you know what I mean YMA yo momma's ass YMMV your mileage may vary YW you're welcome bsd-games-2.17/wtf/Makefrag0000664000175000017500000000351107767741711014260 0ustar jsm28jsm28# Makefrag - makefile fragment for wtf # # Copyright (c) 1999, 2003 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. wtf_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(WTF_ACRONYMFILE)) wtf_all: wtf/wtf wtf/wtf.6 wtf_install: wtf_all $(INSTALL_SCRIPT) wtf/wtf $(INSTALL_PREFIX)$(GAMESDIR)/wtf $(HIDE_GAME) wtf $(INSTALL_DATA) wtf/acronyms $(INSTALL_PREFIX)$(WTF_ACRONYMFILE) $(INSTALL_DATA) wtf/acronyms.comp $(INSTALL_PREFIX)$(WTF_ACRONYMFILE).comp $(INSTALL_MANUAL) wtf/wtf.6 bsd-games-2.17/banner/0000775000175000017500000000000010205246606013245 5ustar jsm28jsm28bsd-games-2.17/banner/Makefile.bsd0000664000175000017500000000022306363445554015466 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.4 1995/03/25 07:44:46 glass Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= banner MAN= banner.6 .include bsd-games-2.17/banner/banner.c0000664000175000017500000022171210005547567014673 0ustar jsm28jsm28/* $NetBSD: banner.c,v 1.12 2004/01/27 20:30:28 jsm Exp $ */ /* * Copyright (c) 1980, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1980, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)banner.c 8.4 (Berkeley) 4/29/95"; #else __RCSID("$NetBSD: banner.c,v 1.12 2004/01/27 20:30:28 jsm Exp $"); #endif #endif /* not lint */ /* * banner - prints large signs * banner [-w width] [-d] [-t] message ... */ #include #include #include #include #include #define MAXMSG 1024 #define DWIDTH 132 #define NCHARS 128 #define NBYTES 9271 /* Pointers into data_table for each ASCII char */ const int asc_ptr[NCHARS] = { /* ^@ */ 0, 0, 0, 0, 0, 0, 0, 0, /* ^H */ 0, 0, 0, 0, 0, 0, 0, 0, /* ^P */ 0, 0, 0, 0, 0, 0, 0, 0, /* ^X */ 0, 0, 0, 0, 0, 0, 0, 0, /* */ 1, 3, 50, 81, 104, 281, 483, 590, /* ( */ 621, 685, 749, 851, 862, 893, 898, 921, /* 0 */1019, 1150, 1200, 1419, 1599, 1744, 1934, 2111, /* 8 */2235, 2445, 2622, 2659, 0, 2708, 0, 2715, /* @ */2857, 3072, 3273, 3403, 3560, 3662, 3730, 3785, /* H */3965, 4000, 4015, 4115, 4281, 4314, 4432, 4548, /* P */4709, 4790, 4999, 5188, 5397, 5448, 5576, 5710, /* X */5892, 6106, 6257, 0, 0, 0, 0, 0, /* ` */ 50, 6503, 6642, 6733, 6837, 6930, 7073, 7157, /* h */7380, 7452, 7499, 7584, 7689, 7702, 7797, 7869, /* p */7978, 8069, 8160, 8222, 8381, 8442, 8508, 8605, /* x */8732, 8888, 9016, 0, 0, 0, 0, 0 }; /* * Table of stuff to print. Format: * 128+n -> print current line n times. * 64+n -> this is last byte of char. * else, put m chars at position n (where m * is the next elt in array) and goto second * next element in array. */ const char data_table[NBYTES] = { /* 0 1 2 3 4 5 6 7 8 9 */ /* 0 */ 129, 227, 130, 34, 6, 90, 19, 129, 32, 10, /* 10 */ 74, 40, 129, 31, 12, 64, 53, 129, 30, 14, /* 20 */ 54, 65, 129, 30, 14, 53, 67, 129, 30, 14, /* 30 */ 54, 65, 129, 31, 12, 64, 53, 129, 32, 10, /* 40 */ 74, 40, 129, 34, 6, 90, 19, 129, 194, 130, /* 50 */ 99, 9, 129, 97, 14, 129, 96, 18, 129, 95, /* 60 */ 22, 129, 95, 16, 117, 2, 129, 95, 14, 129, /* 70 */ 96, 11, 129, 97, 9, 129, 99, 6, 129, 194, /* 80 */ 129, 87, 4, 101, 4, 131, 82, 28, 131, 87, /* 90 */ 4, 101, 4, 133, 82, 28, 131, 87, 4, 101, /* 100 */ 4, 131, 193, 129, 39, 1, 84, 27, 129, 38, /* 110 */ 3, 81, 32, 129, 37, 5, 79, 35, 129, 36, /* 120 */ 5, 77, 38, 129, 35, 5, 76, 40, 129, 34, /* 130 */ 5, 75, 21, 103, 14, 129, 33, 5, 74, 19, /* 140 */ 107, 11, 129, 32, 5, 73, 17, 110, 9, 129, /* 150 */ 32, 4, 73, 16, 112, 7, 129, 31, 4, 72, /* 160 */ 15, 114, 6, 129, 31, 4, 72, 14, 115, 5, /* 170 */ 129, 30, 4, 71, 15, 116, 5, 129, 27, 97, /* 180 */ 131, 30, 4, 69, 14, 117, 4, 129, 30, 4, /* 190 */ 68, 15, 117, 4, 132, 30, 4, 68, 14, 117, /* 200 */ 4, 129, 27, 97, 131, 30, 5, 65, 15, 116, /* 210 */ 5, 129, 31, 4, 65, 14, 116, 4, 129, 31, /* 220 */ 6, 64, 15, 116, 4, 129, 32, 7, 62, 16, /* 230 */ 115, 4, 129, 32, 9, 61, 17, 114, 5, 129, /* 240 */ 33, 11, 58, 19, 113, 5, 129, 34, 14, 55, /* 250 */ 21, 112, 5, 129, 35, 40, 111, 5, 129, 36, /* 260 */ 38, 110, 5, 129, 37, 35, 109, 5, 129, 38, /* 270 */ 32, 110, 3, 129, 40, 27, 111, 1, 129, 193, /* 280 */ 129, 30, 4, 103, 9, 129, 30, 7, 100, 15, /* 290 */ 129, 30, 10, 99, 17, 129, 33, 10, 97, 6, /* 300 */ 112, 6, 129, 36, 10, 96, 5, 114, 5, 129, /* 310 */ 39, 10, 96, 4, 115, 4, 129, 42, 10, 95, /* 320 */ 4, 116, 4, 129, 45, 10, 95, 3, 117, 3, /* 330 */ 129, 48, 10, 95, 3, 117, 3, 129, 51, 10, /* 340 */ 95, 4, 116, 4, 129, 54, 10, 96, 4, 115, /* 350 */ 4, 129, 57, 10, 96, 5, 114, 5, 129, 60, /* 360 */ 10, 97, 6, 112, 6, 129, 63, 10, 99, 17, /* 370 */ 129, 66, 10, 100, 15, 129, 69, 10, 103, 9, /* 380 */ 129, 39, 9, 72, 10, 129, 36, 15, 75, 10, /* 390 */ 129, 35, 17, 78, 10, 129, 33, 6, 48, 6, /* 400 */ 81, 10, 129, 32, 5, 50, 5, 84, 10, 129, /* 410 */ 32, 4, 51, 4, 87, 10, 129, 31, 4, 52, /* 420 */ 4, 90, 10, 129, 31, 3, 53, 3, 93, 10, /* 430 */ 129, 31, 3, 53, 3, 96, 10, 129, 31, 4, /* 440 */ 52, 4, 99, 10, 129, 32, 4, 51, 4, 102, /* 450 */ 10, 129, 32, 5, 50, 5, 105, 10, 129, 33, /* 460 */ 6, 48, 6, 108, 10, 129, 35, 17, 111, 10, /* 470 */ 129, 36, 15, 114, 7, 129, 40, 9, 118, 4, /* 480 */ 129, 193, 129, 48, 18, 129, 43, 28, 129, 41, /* 490 */ 32, 129, 39, 36, 129, 37, 40, 129, 35, 44, /* 500 */ 129, 34, 46, 129, 33, 13, 68, 13, 129, 32, /* 510 */ 9, 73, 9, 129, 32, 7, 75, 7, 129, 31, /* 520 */ 6, 77, 6, 129, 31, 5, 78, 5, 129, 30, /* 530 */ 5, 79, 5, 129, 20, 74, 132, 30, 4, 80, /* 540 */ 4, 129, 31, 3, 79, 4, 129, 31, 4, 79, /* 550 */ 4, 129, 32, 3, 78, 4, 129, 32, 4, 76, /* 560 */ 6, 129, 33, 4, 74, 7, 129, 34, 4, 72, /* 570 */ 8, 129, 35, 5, 72, 7, 129, 37, 5, 73, /* 580 */ 4, 129, 39, 4, 74, 1, 129, 129, 193, 130, /* 590 */ 111, 6, 129, 109, 10, 129, 108, 12, 129, 107, /* 600 */ 14, 129, 97, 2, 105, 16, 129, 99, 22, 129, /* 610 */ 102, 18, 129, 105, 14, 129, 108, 9, 129, 194, /* 620 */ 130, 63, 25, 129, 57, 37, 129, 52, 47, 129, /* 630 */ 48, 55, 129, 44, 63, 129, 41, 69, 129, 38, /* 640 */ 75, 129, 36, 79, 129, 34, 83, 129, 33, 28, /* 650 */ 90, 28, 129, 32, 23, 96, 23, 129, 32, 17, /* 660 */ 102, 17, 129, 31, 13, 107, 13, 129, 30, 9, /* 670 */ 112, 9, 129, 30, 5, 116, 5, 129, 30, 1, /* 680 */ 120, 1, 129, 194, 130, 30, 1, 120, 1, 129, /* 690 */ 30, 5, 116, 5, 129, 30, 9, 112, 9, 129, /* 700 */ 31, 13, 107, 13, 129, 32, 17, 102, 17, 129, /* 710 */ 32, 23, 96, 23, 129, 33, 28, 90, 28, 129, /* 720 */ 34, 83, 129, 36, 79, 129, 38, 75, 129, 41, /* 730 */ 69, 129, 44, 63, 129, 48, 55, 129, 52, 47, /* 740 */ 129, 57, 37, 129, 63, 25, 129, 194, 129, 80, /* 750 */ 4, 130, 80, 4, 129, 68, 2, 80, 4, 94, /* 760 */ 2, 129, 66, 6, 80, 4, 92, 6, 129, 67, /* 770 */ 7, 80, 4, 90, 7, 129, 69, 7, 80, 4, /* 780 */ 88, 7, 129, 71, 6, 80, 4, 87, 6, 129, /* 790 */ 72, 20, 129, 74, 16, 129, 76, 12, 129, 62, /* 800 */ 40, 131, 76, 12, 129, 74, 16, 129, 72, 20, /* 810 */ 129, 71, 6, 80, 4, 87, 6, 129, 69, 7, /* 820 */ 80, 4, 88, 7, 129, 67, 7, 80, 4, 90, /* 830 */ 7, 129, 66, 6, 80, 4, 92, 6, 129, 68, /* 840 */ 2, 80, 4, 94, 2, 129, 80, 4, 130, 193, /* 850 */ 129, 60, 4, 139, 41, 42, 131, 60, 4, 139, /* 860 */ 193, 130, 34, 6, 129, 32, 10, 129, 31, 12, /* 870 */ 129, 30, 14, 129, 20, 2, 28, 16, 129, 22, /* 880 */ 22, 129, 24, 19, 129, 27, 15, 129, 31, 9, /* 890 */ 129, 194, 129, 60, 4, 152, 193, 130, 34, 6, /* 900 */ 129, 32, 10, 129, 31, 12, 129, 30, 14, 131, /* 910 */ 31, 12, 129, 32, 10, 129, 34, 6, 129, 194, /* 920 */ 129, 30, 4, 129, 30, 7, 129, 30, 10, 129, /* 930 */ 33, 10, 129, 36, 10, 129, 39, 10, 129, 42, /* 940 */ 10, 129, 45, 10, 129, 48, 10, 129, 51, 10, /* 950 */ 129, 54, 10, 129, 57, 10, 129, 60, 10, 129, /* 960 */ 63, 10, 129, 66, 10, 129, 69, 10, 129, 72, /* 970 */ 10, 129, 75, 10, 129, 78, 10, 129, 81, 10, /* 980 */ 129, 84, 10, 129, 87, 10, 129, 90, 10, 129, /* 990 */ 93, 10, 129, 96, 10, 129, 99, 10, 129, 102, /* 1000 */ 10, 129, 105, 10, 129, 108, 10, 129, 111, 10, /* 1010 */ 129, 114, 7, 129, 117, 4, 129, 193, 129, 60, /* 1020 */ 31, 129, 53, 45, 129, 49, 53, 129, 46, 59, /* 1030 */ 129, 43, 65, 129, 41, 69, 129, 39, 73, 129, /* 1040 */ 37, 77, 129, 36, 79, 129, 35, 15, 101, 15, /* 1050 */ 129, 34, 11, 106, 11, 129, 33, 9, 109, 9, /* 1060 */ 129, 32, 7, 112, 7, 129, 31, 6, 114, 6, /* 1070 */ 129, 31, 5, 115, 5, 129, 30, 5, 116, 5, /* 1080 */ 129, 30, 4, 117, 4, 132, 30, 5, 116, 5, /* 1090 */ 129, 31, 5, 115, 5, 129, 31, 6, 114, 6, /* 1100 */ 129, 32, 7, 112, 7, 129, 33, 9, 109, 9, /* 1110 */ 129, 34, 11, 106, 11, 129, 35, 15, 101, 15, /* 1120 */ 129, 36, 79, 129, 37, 77, 129, 39, 73, 129, /* 1130 */ 41, 69, 129, 43, 65, 129, 46, 59, 129, 49, /* 1140 */ 53, 129, 53, 45, 129, 60, 31, 129, 193, 129, /* 1150 */ 30, 4, 129, 30, 4, 100, 1, 129, 30, 4, /* 1160 */ 100, 3, 129, 30, 4, 100, 5, 129, 30, 76, /* 1170 */ 129, 30, 78, 129, 30, 80, 129, 30, 82, 129, /* 1180 */ 30, 83, 129, 30, 85, 129, 30, 87, 129, 30, /* 1190 */ 89, 129, 30, 91, 129, 30, 4, 132, 193, 129, /* 1200 */ 30, 3, 129, 30, 7, 129, 30, 10, 112, 1, /* 1210 */ 129, 30, 13, 112, 2, 129, 30, 16, 112, 3, /* 1220 */ 129, 30, 18, 111, 5, 129, 30, 21, 111, 6, /* 1230 */ 129, 30, 23, 112, 6, 129, 30, 14, 47, 8, /* 1240 */ 113, 6, 129, 30, 14, 49, 8, 114, 5, 129, /* 1250 */ 30, 14, 51, 8, 115, 5, 129, 30, 14, 53, /* 1260 */ 8, 116, 4, 129, 30, 14, 55, 8, 116, 5, /* 1270 */ 129, 30, 14, 56, 9, 117, 4, 129, 30, 14, /* 1280 */ 57, 9, 117, 4, 129, 30, 14, 58, 10, 117, /* 1290 */ 4, 129, 30, 14, 59, 10, 117, 4, 129, 30, /* 1300 */ 14, 60, 11, 117, 4, 129, 30, 14, 61, 11, /* 1310 */ 116, 5, 129, 30, 14, 62, 11, 116, 5, 129, /* 1320 */ 30, 14, 63, 12, 115, 6, 129, 30, 14, 64, /* 1330 */ 13, 114, 7, 129, 30, 14, 65, 13, 113, 8, /* 1340 */ 129, 30, 14, 65, 15, 111, 9, 129, 30, 14, /* 1350 */ 66, 16, 109, 11, 129, 30, 14, 67, 17, 107, /* 1360 */ 12, 129, 30, 14, 68, 20, 103, 16, 129, 30, /* 1370 */ 14, 69, 49, 129, 30, 14, 70, 47, 129, 30, /* 1380 */ 14, 71, 45, 129, 30, 14, 73, 42, 129, 30, /* 1390 */ 15, 75, 38, 129, 33, 12, 77, 34, 129, 36, /* 1400 */ 10, 79, 30, 129, 40, 6, 82, 23, 129, 44, /* 1410 */ 3, 86, 15, 129, 47, 1, 129, 193, 129, 129, /* 1420 */ 38, 3, 129, 37, 5, 111, 1, 129, 36, 7, /* 1430 */ 111, 2, 129, 35, 9, 110, 5, 129, 34, 8, /* 1440 */ 110, 6, 129, 33, 7, 109, 8, 129, 32, 7, /* 1450 */ 110, 8, 129, 32, 6, 112, 7, 129, 31, 6, /* 1460 */ 113, 6, 129, 31, 5, 114, 6, 129, 30, 5, /* 1470 */ 115, 5, 129, 30, 5, 116, 4, 129, 30, 4, /* 1480 */ 117, 4, 131, 30, 4, 117, 4, 129, 30, 4, /* 1490 */ 79, 2, 117, 4, 129, 30, 5, 78, 4, 117, /* 1500 */ 4, 129, 30, 5, 77, 6, 116, 5, 129, 30, /* 1510 */ 6, 76, 8, 115, 6, 129, 30, 7, 75, 11, /* 1520 */ 114, 6, 129, 30, 8, 73, 15, 112, 8, 129, /* 1530 */ 31, 9, 71, 19, 110, 9, 129, 31, 11, 68, /* 1540 */ 26, 107, 12, 129, 32, 13, 65, 14, 82, 36, /* 1550 */ 129, 32, 16, 61, 17, 83, 34, 129, 33, 44, /* 1560 */ 84, 32, 129, 34, 42, 85, 30, 129, 35, 40, /* 1570 */ 87, 27, 129, 36, 38, 89, 23, 129, 38, 34, /* 1580 */ 92, 17, 129, 40, 30, 95, 11, 129, 42, 26, /* 1590 */ 129, 45, 20, 129, 49, 11, 129, 193, 129, 49, /* 1600 */ 1, 129, 49, 4, 129, 49, 6, 129, 49, 8, /* 1610 */ 129, 49, 10, 129, 49, 12, 129, 49, 14, 129, /* 1620 */ 49, 17, 129, 49, 19, 129, 49, 21, 129, 49, /* 1630 */ 23, 129, 49, 14, 65, 9, 129, 49, 14, 67, /* 1640 */ 9, 129, 49, 14, 69, 9, 129, 49, 14, 71, /* 1650 */ 10, 129, 49, 14, 74, 9, 129, 49, 14, 76, /* 1660 */ 9, 129, 49, 14, 78, 9, 129, 49, 14, 80, /* 1670 */ 9, 129, 49, 14, 82, 9, 129, 49, 14, 84, /* 1680 */ 9, 129, 30, 4, 49, 14, 86, 10, 129, 30, /* 1690 */ 4, 49, 14, 89, 9, 129, 30, 4, 49, 14, /* 1700 */ 91, 9, 129, 30, 4, 49, 14, 93, 9, 129, /* 1710 */ 30, 74, 129, 30, 76, 129, 30, 78, 129, 30, /* 1720 */ 81, 129, 30, 83, 129, 30, 85, 129, 30, 87, /* 1730 */ 129, 30, 89, 129, 30, 91, 129, 30, 4, 49, /* 1740 */ 14, 132, 193, 129, 37, 1, 129, 36, 3, 77, /* 1750 */ 3, 129, 35, 5, 78, 11, 129, 34, 7, 78, /* 1760 */ 21, 129, 33, 7, 79, 29, 129, 32, 7, 79, /* 1770 */ 38, 129, 32, 6, 80, 4, 92, 29, 129, 31, /* 1780 */ 6, 80, 5, 102, 19, 129, 31, 5, 80, 6, /* 1790 */ 107, 14, 129, 31, 4, 81, 5, 107, 14, 129, /* 1800 */ 30, 5, 81, 6, 107, 14, 129, 30, 4, 81, /* 1810 */ 6, 107, 14, 130, 30, 4, 81, 7, 107, 14, /* 1820 */ 129, 30, 4, 80, 8, 107, 14, 130, 30, 5, /* 1830 */ 80, 8, 107, 14, 129, 30, 5, 79, 9, 107, /* 1840 */ 14, 129, 31, 5, 79, 9, 107, 14, 129, 31, /* 1850 */ 6, 78, 10, 107, 14, 129, 32, 6, 76, 11, /* 1860 */ 107, 14, 129, 32, 8, 74, 13, 107, 14, 129, /* 1870 */ 33, 10, 71, 16, 107, 14, 129, 33, 15, 67, /* 1880 */ 19, 107, 14, 129, 34, 51, 107, 14, 129, 35, /* 1890 */ 49, 107, 14, 129, 36, 47, 107, 14, 129, 37, /* 1900 */ 45, 107, 14, 129, 39, 41, 107, 14, 129, 41, /* 1910 */ 37, 107, 14, 129, 44, 32, 107, 14, 129, 47, /* 1920 */ 25, 111, 10, 129, 51, 16, 115, 6, 129, 119, /* 1930 */ 2, 129, 193, 129, 56, 39, 129, 51, 49, 129, /* 1940 */ 47, 57, 129, 44, 63, 129, 42, 67, 129, 40, /* 1950 */ 71, 129, 38, 75, 129, 37, 77, 129, 35, 81, /* 1960 */ 129, 34, 16, 74, 5, 101, 16, 129, 33, 11, /* 1970 */ 76, 5, 107, 11, 129, 32, 9, 77, 5, 110, /* 1980 */ 9, 129, 32, 7, 79, 4, 112, 7, 129, 31, /* 1990 */ 6, 80, 4, 114, 6, 129, 31, 5, 81, 4, /* 2000 */ 115, 5, 129, 30, 5, 82, 4, 116, 5, 129, /* 2010 */ 30, 4, 82, 4, 116, 5, 129, 30, 4, 82, /* 2020 */ 5, 117, 4, 131, 30, 5, 82, 5, 117, 4, /* 2030 */ 129, 31, 5, 81, 6, 117, 4, 129, 31, 6, /* 2040 */ 80, 7, 117, 4, 129, 32, 7, 79, 8, 117, /* 2050 */ 4, 129, 32, 9, 77, 9, 116, 5, 129, 33, /* 2060 */ 11, 75, 11, 116, 4, 129, 34, 16, 69, 16, /* 2070 */ 115, 5, 129, 35, 49, 114, 5, 129, 37, 46, /* 2080 */ 113, 5, 129, 38, 44, 112, 6, 129, 40, 41, /* 2090 */ 112, 5, 129, 42, 37, 113, 3, 129, 44, 33, /* 2100 */ 114, 1, 129, 47, 27, 129, 51, 17, 129, 193, /* 2110 */ 129, 103, 2, 129, 103, 6, 129, 104, 9, 129, /* 2120 */ 105, 12, 129, 106, 15, 129, 107, 14, 135, 30, /* 2130 */ 10, 107, 14, 129, 30, 17, 107, 14, 129, 30, /* 2140 */ 25, 107, 14, 129, 30, 31, 107, 14, 129, 30, /* 2150 */ 37, 107, 14, 129, 30, 42, 107, 14, 129, 30, /* 2160 */ 46, 107, 14, 129, 30, 50, 107, 14, 129, 30, /* 2170 */ 54, 107, 14, 129, 30, 58, 107, 14, 129, 59, /* 2180 */ 32, 107, 14, 129, 64, 30, 107, 14, 129, 74, /* 2190 */ 23, 107, 14, 129, 81, 18, 107, 14, 129, 86, /* 2200 */ 16, 107, 14, 129, 91, 14, 107, 14, 129, 96, /* 2210 */ 25, 129, 100, 21, 129, 104, 17, 129, 107, 14, /* 2220 */ 129, 111, 10, 129, 114, 7, 129, 117, 4, 129, /* 2230 */ 120, 1, 129, 193, 129, 48, 13, 129, 44, 21, /* 2240 */ 129, 42, 26, 129, 40, 30, 92, 12, 129, 38, /* 2250 */ 34, 88, 20, 129, 36, 37, 86, 25, 129, 35, /* 2260 */ 39, 84, 29, 129, 34, 13, 63, 12, 82, 33, /* 2270 */ 129, 33, 11, 67, 9, 80, 36, 129, 32, 9, /* 2280 */ 70, 7, 79, 38, 129, 31, 8, 72, 46, 129, /* 2290 */ 30, 7, 74, 22, 108, 11, 129, 30, 6, 75, /* 2300 */ 19, 111, 9, 129, 30, 5, 75, 17, 113, 7, /* 2310 */ 129, 30, 5, 74, 16, 114, 6, 129, 30, 4, /* 2320 */ 73, 16, 115, 6, 129, 30, 4, 72, 16, 116, /* 2330 */ 5, 129, 30, 4, 72, 15, 117, 4, 129, 30, /* 2340 */ 4, 71, 16, 117, 4, 129, 30, 5, 70, 16, /* 2350 */ 117, 4, 129, 30, 5, 70, 15, 117, 4, 129, /* 2360 */ 30, 6, 69, 15, 116, 5, 129, 30, 7, 68, /* 2370 */ 17, 115, 5, 129, 30, 9, 67, 19, 114, 6, /* 2380 */ 129, 30, 10, 65, 22, 113, 6, 129, 31, 12, /* 2390 */ 63, 27, 110, 9, 129, 32, 14, 60, 21, 84, /* 2400 */ 9, 106, 12, 129, 33, 47, 85, 32, 129, 34, /* 2410 */ 45, 86, 30, 129, 35, 43, 88, 26, 129, 36, /* 2420 */ 40, 90, 22, 129, 38, 36, 93, 17, 129, 40, /* 2430 */ 32, 96, 10, 129, 42, 28, 129, 44, 23, 129, /* 2440 */ 48, 15, 129, 193, 129, 83, 17, 129, 77, 27, /* 2450 */ 129, 36, 1, 74, 33, 129, 35, 3, 72, 37, /* 2460 */ 129, 34, 5, 70, 41, 129, 33, 6, 69, 44, /* 2470 */ 129, 33, 5, 68, 46, 129, 32, 5, 67, 49, /* 2480 */ 129, 31, 5, 66, 17, 101, 16, 129, 31, 5, /* 2490 */ 66, 11, 108, 10, 129, 30, 4, 65, 9, 110, /* 2500 */ 9, 129, 30, 4, 64, 8, 112, 7, 129, 30, /* 2510 */ 4, 64, 7, 114, 6, 129, 30, 4, 64, 6, /* 2520 */ 115, 5, 129, 30, 4, 64, 5, 116, 5, 129, /* 2530 */ 30, 4, 64, 5, 117, 4, 131, 30, 4, 65, /* 2540 */ 4, 117, 4, 129, 30, 5, 65, 4, 116, 5, /* 2550 */ 129, 31, 5, 66, 4, 115, 5, 129, 31, 6, /* 2560 */ 67, 4, 114, 6, 129, 32, 7, 68, 4, 112, /* 2570 */ 7, 129, 32, 9, 69, 5, 110, 9, 129, 33, /* 2580 */ 11, 70, 5, 107, 11, 129, 34, 16, 72, 5, /* 2590 */ 101, 16, 129, 35, 81, 129, 37, 77, 129, 38, /* 2600 */ 75, 129, 40, 71, 129, 42, 67, 129, 44, 63, /* 2610 */ 129, 47, 57, 129, 51, 49, 129, 56, 39, 129, /* 2620 */ 193, 130, 34, 6, 74, 6, 129, 32, 10, 72, /* 2630 */ 10, 129, 31, 12, 71, 12, 129, 30, 14, 70, /* 2640 */ 14, 131, 31, 12, 71, 12, 129, 32, 10, 72, /* 2650 */ 10, 129, 34, 6, 74, 6, 129, 194, 130, 34, /* 2660 */ 6, 74, 6, 129, 32, 10, 72, 10, 129, 31, /* 2670 */ 12, 71, 12, 129, 30, 14, 70, 14, 129, 20, /* 2680 */ 2, 28, 16, 70, 14, 129, 22, 22, 70, 14, /* 2690 */ 129, 24, 19, 71, 12, 129, 27, 15, 72, 10, /* 2700 */ 129, 31, 9, 74, 6, 129, 194, 129, 53, 4, /* 2710 */ 63, 4, 152, 193, 130, 99, 7, 129, 97, 13, /* 2720 */ 129, 96, 16, 129, 96, 18, 129, 96, 19, 129, /* 2730 */ 97, 19, 129, 99, 6, 110, 7, 129, 112, 6, /* 2740 */ 129, 114, 5, 129, 34, 6, 57, 5, 115, 4, /* 2750 */ 129, 32, 10, 54, 12, 116, 4, 129, 31, 12, /* 2760 */ 53, 16, 117, 3, 129, 30, 14, 52, 20, 117, /* 2770 */ 4, 129, 30, 14, 52, 23, 117, 4, 129, 30, /* 2780 */ 14, 52, 25, 117, 4, 129, 31, 12, 52, 27, /* 2790 */ 117, 4, 129, 32, 10, 53, 10, 70, 11, 116, /* 2800 */ 5, 129, 34, 6, 55, 5, 73, 10, 115, 6, /* 2810 */ 129, 74, 11, 114, 7, 129, 75, 12, 112, 9, /* 2820 */ 129, 76, 13, 110, 10, 129, 77, 16, 106, 14, /* 2830 */ 129, 78, 41, 129, 80, 38, 129, 81, 36, 129, /* 2840 */ 82, 34, 129, 84, 30, 129, 86, 26, 129, 88, /* 2850 */ 22, 129, 92, 14, 129, 194, 129, 55, 15, 129, /* 2860 */ 50, 25, 129, 47, 32, 129, 45, 13, 70, 12, /* 2870 */ 129, 43, 9, 76, 10, 129, 42, 6, 79, 8, /* 2880 */ 129, 41, 5, 81, 7, 129, 40, 4, 84, 6, /* 2890 */ 129, 39, 4, 59, 12, 85, 6, 129, 38, 4, /* 2900 */ 55, 19, 87, 5, 129, 37, 4, 53, 23, 88, /* 2910 */ 4, 129, 36, 4, 51, 8, 71, 6, 89, 4, /* 2920 */ 129, 36, 4, 51, 6, 73, 4, 89, 4, 129, /* 2930 */ 36, 4, 50, 6, 74, 4, 90, 3, 129, 35, /* 2940 */ 4, 50, 5, 75, 3, 90, 4, 129, 35, 4, /* 2950 */ 50, 4, 75, 4, 90, 4, 131, 35, 4, 50, /* 2960 */ 5, 75, 4, 90, 4, 129, 36, 4, 51, 5, /* 2970 */ 75, 4, 90, 4, 129, 36, 4, 51, 6, 75, /* 2980 */ 4, 90, 4, 129, 36, 4, 53, 26, 90, 4, /* 2990 */ 129, 37, 4, 54, 25, 90, 4, 129, 37, 4, /* 3000 */ 52, 27, 90, 3, 129, 38, 4, 52, 4, 89, /* 3010 */ 4, 129, 39, 4, 51, 4, 88, 4, 129, 40, /* 3020 */ 4, 50, 4, 87, 5, 129, 41, 4, 50, 4, /* 3030 */ 86, 5, 129, 42, 4, 50, 4, 85, 5, 129, /* 3040 */ 43, 3, 50, 4, 83, 6, 129, 44, 2, 51, /* 3050 */ 5, 80, 7, 129, 46, 1, 52, 6, 76, 9, /* 3060 */ 129, 54, 28, 129, 56, 23, 129, 60, 16, 129, /* 3070 */ 193, 129, 30, 4, 132, 30, 5, 129, 30, 8, /* 3080 */ 129, 30, 12, 129, 30, 16, 129, 30, 4, 37, /* 3090 */ 12, 129, 30, 4, 41, 12, 129, 30, 4, 44, /* 3100 */ 13, 129, 30, 4, 48, 13, 129, 52, 13, 129, /* 3110 */ 56, 12, 129, 58, 14, 129, 58, 4, 64, 12, /* 3120 */ 129, 58, 4, 68, 12, 129, 58, 4, 72, 12, /* 3130 */ 129, 58, 4, 75, 13, 129, 58, 4, 79, 13, /* 3140 */ 129, 58, 4, 83, 13, 129, 58, 4, 87, 13, /* 3150 */ 129, 58, 4, 91, 12, 129, 58, 4, 95, 12, /* 3160 */ 129, 58, 4, 96, 15, 129, 58, 4, 93, 22, /* 3170 */ 129, 58, 4, 89, 30, 129, 58, 4, 85, 36, /* 3180 */ 129, 58, 4, 81, 38, 129, 58, 4, 77, 38, /* 3190 */ 129, 58, 4, 73, 38, 129, 58, 4, 70, 37, /* 3200 */ 129, 58, 4, 66, 37, 129, 58, 41, 129, 58, /* 3210 */ 37, 129, 54, 38, 129, 30, 4, 50, 38, 129, /* 3220 */ 30, 4, 46, 38, 129, 30, 4, 42, 38, 129, /* 3230 */ 30, 4, 38, 39, 129, 30, 43, 129, 30, 39, /* 3240 */ 129, 30, 35, 129, 30, 31, 129, 30, 27, 129, /* 3250 */ 30, 24, 129, 30, 20, 129, 30, 16, 129, 30, /* 3260 */ 12, 129, 30, 8, 129, 30, 5, 129, 30, 4, /* 3270 */ 132, 193, 129, 30, 4, 117, 4, 132, 30, 91, /* 3280 */ 137, 30, 4, 80, 4, 117, 4, 138, 30, 4, /* 3290 */ 80, 5, 116, 5, 129, 30, 5, 79, 6, 116, /* 3300 */ 5, 130, 30, 6, 78, 8, 115, 6, 129, 31, /* 3310 */ 6, 77, 9, 115, 6, 129, 31, 7, 76, 11, /* 3320 */ 114, 6, 129, 31, 8, 75, 14, 112, 8, 129, /* 3330 */ 32, 8, 74, 16, 111, 9, 129, 32, 9, 73, /* 3340 */ 19, 109, 10, 129, 33, 10, 71, 24, 106, 13, /* 3350 */ 129, 33, 13, 68, 12, 83, 35, 129, 34, 16, /* 3360 */ 64, 15, 84, 33, 129, 35, 43, 85, 31, 129, /* 3370 */ 36, 41, 86, 29, 129, 37, 39, 88, 25, 129, /* 3380 */ 38, 37, 90, 21, 129, 40, 33, 93, 15, 129, /* 3390 */ 42, 29, 96, 9, 129, 45, 24, 129, 49, 16, /* 3400 */ 129, 193, 129, 63, 25, 129, 57, 37, 129, 53, /* 3410 */ 45, 129, 50, 51, 129, 47, 57, 129, 45, 61, /* 3420 */ 129, 43, 65, 129, 41, 69, 129, 39, 73, 129, /* 3430 */ 38, 25, 92, 21, 129, 36, 21, 97, 18, 129, /* 3440 */ 35, 18, 102, 14, 129, 34, 16, 106, 11, 129, /* 3450 */ 33, 14, 108, 10, 129, 32, 12, 111, 8, 129, /* 3460 */ 32, 10, 113, 6, 129, 31, 10, 114, 6, 129, /* 3470 */ 31, 8, 115, 5, 129, 30, 8, 116, 5, 129, /* 3480 */ 30, 7, 116, 5, 129, 30, 6, 117, 4, 130, /* 3490 */ 30, 5, 117, 4, 131, 31, 4, 116, 5, 129, /* 3500 */ 32, 4, 116, 4, 129, 32, 5, 115, 5, 129, /* 3510 */ 33, 4, 114, 5, 129, 34, 4, 112, 6, 129, /* 3520 */ 35, 4, 110, 7, 129, 37, 4, 107, 9, 129, /* 3530 */ 39, 4, 103, 12, 129, 41, 4, 103, 18, 129, /* 3540 */ 43, 4, 103, 18, 129, 45, 5, 103, 18, 129, /* 3550 */ 48, 5, 103, 18, 129, 51, 1, 129, 193, 129, /* 3560 */ 30, 4, 117, 4, 132, 30, 91, 137, 30, 4, /* 3570 */ 117, 4, 135, 30, 5, 116, 5, 130, 30, 6, /* 3580 */ 115, 6, 130, 31, 6, 114, 6, 129, 31, 7, /* 3590 */ 113, 7, 129, 32, 7, 112, 7, 129, 32, 8, /* 3600 */ 111, 8, 129, 33, 9, 109, 9, 129, 33, 12, /* 3610 */ 106, 12, 129, 34, 13, 104, 13, 129, 35, 15, /* 3620 */ 101, 15, 129, 36, 19, 96, 19, 129, 37, 24, /* 3630 */ 90, 24, 129, 39, 73, 129, 40, 71, 129, 42, /* 3640 */ 67, 129, 44, 63, 129, 46, 59, 129, 49, 53, /* 3650 */ 129, 52, 47, 129, 56, 39, 129, 61, 29, 129, /* 3660 */ 193, 129, 30, 4, 117, 4, 132, 30, 91, 137, /* 3670 */ 30, 4, 80, 4, 117, 4, 140, 30, 4, 79, /* 3680 */ 6, 117, 4, 129, 30, 4, 77, 10, 117, 4, /* 3690 */ 129, 30, 4, 73, 18, 117, 4, 132, 30, 4, /* 3700 */ 117, 4, 130, 30, 5, 116, 5, 130, 30, 7, /* 3710 */ 114, 7, 129, 30, 8, 113, 8, 129, 30, 11, /* 3720 */ 110, 11, 129, 30, 18, 103, 18, 132, 193, 129, /* 3730 */ 30, 4, 117, 4, 132, 30, 91, 137, 30, 4, /* 3740 */ 80, 4, 117, 4, 132, 80, 4, 117, 4, 136, /* 3750 */ 79, 6, 117, 4, 129, 77, 10, 117, 4, 129, /* 3760 */ 73, 18, 117, 4, 132, 117, 4, 130, 116, 5, /* 3770 */ 130, 114, 7, 129, 113, 8, 129, 110, 11, 129, /* 3780 */ 103, 18, 132, 193, 129, 63, 25, 129, 57, 37, /* 3790 */ 129, 53, 45, 129, 50, 51, 129, 47, 57, 129, /* 3800 */ 45, 61, 129, 43, 65, 129, 41, 69, 129, 39, /* 3810 */ 73, 129, 38, 25, 92, 21, 129, 36, 21, 97, /* 3820 */ 18, 129, 35, 18, 102, 14, 129, 34, 16, 106, /* 3830 */ 11, 129, 33, 14, 108, 10, 129, 32, 12, 111, /* 3840 */ 8, 129, 32, 10, 113, 6, 129, 31, 10, 114, /* 3850 */ 6, 129, 31, 8, 115, 5, 129, 30, 8, 116, /* 3860 */ 5, 129, 30, 7, 116, 5, 129, 30, 6, 117, /* 3870 */ 4, 130, 30, 5, 117, 4, 131, 30, 5, 75, /* 3880 */ 4, 116, 5, 129, 31, 5, 75, 4, 116, 4, /* 3890 */ 129, 31, 6, 75, 4, 115, 5, 129, 32, 7, /* 3900 */ 75, 4, 114, 5, 129, 32, 9, 75, 4, 112, /* 3910 */ 6, 129, 33, 11, 75, 4, 110, 7, 129, 34, /* 3920 */ 15, 75, 4, 107, 9, 129, 35, 44, 103, 12, /* 3930 */ 129, 36, 43, 103, 18, 129, 38, 41, 103, 18, /* 3940 */ 129, 39, 40, 103, 18, 129, 41, 38, 103, 18, /* 3950 */ 129, 44, 35, 129, 48, 31, 129, 52, 27, 129, /* 3960 */ 61, 18, 129, 193, 129, 30, 4, 117, 4, 132, /* 3970 */ 30, 91, 137, 30, 4, 80, 4, 117, 4, 132, /* 3980 */ 80, 4, 140, 30, 4, 80, 4, 117, 4, 132, /* 3990 */ 30, 91, 137, 30, 4, 117, 4, 132, 193, 129, /* 4000 */ 30, 4, 117, 4, 132, 30, 91, 137, 30, 4, /* 4010 */ 117, 4, 132, 193, 129, 44, 7, 129, 40, 13, /* 4020 */ 129, 37, 17, 129, 35, 20, 129, 34, 22, 129, /* 4030 */ 33, 23, 129, 32, 24, 129, 32, 23, 129, 31, /* 4040 */ 6, 41, 13, 129, 31, 5, 42, 11, 129, 30, /* 4050 */ 5, 44, 7, 129, 30, 4, 132, 30, 5, 130, /* 4060 */ 31, 5, 129, 31, 6, 117, 4, 129, 31, 8, /* 4070 */ 117, 4, 129, 32, 9, 117, 4, 129, 33, 11, /* 4080 */ 117, 4, 129, 34, 87, 129, 35, 86, 129, 36, /* 4090 */ 85, 129, 37, 84, 129, 38, 83, 129, 40, 81, /* 4100 */ 129, 42, 79, 129, 45, 76, 129, 50, 71, 129, /* 4110 */ 117, 4, 132, 193, 129, 30, 4, 117, 4, 132, /* 4120 */ 30, 91, 137, 30, 4, 76, 8, 117, 4, 129, /* 4130 */ 30, 4, 73, 13, 117, 4, 129, 30, 4, 70, /* 4140 */ 18, 117, 4, 129, 30, 4, 67, 23, 117, 4, /* 4150 */ 129, 65, 26, 129, 62, 31, 129, 59, 35, 129, /* 4160 */ 56, 29, 89, 7, 129, 53, 29, 91, 7, 129, /* 4170 */ 50, 29, 93, 7, 129, 47, 29, 95, 6, 129, /* 4180 */ 30, 4, 45, 29, 96, 7, 129, 30, 4, 42, /* 4190 */ 29, 98, 7, 129, 30, 4, 39, 30, 100, 6, /* 4200 */ 129, 30, 4, 36, 30, 101, 7, 129, 30, 33, /* 4210 */ 103, 7, 117, 4, 129, 30, 30, 105, 6, 117, /* 4220 */ 4, 129, 30, 27, 106, 7, 117, 4, 129, 30, /* 4230 */ 25, 108, 7, 117, 4, 129, 30, 22, 110, 11, /* 4240 */ 129, 30, 19, 111, 10, 129, 30, 16, 113, 8, /* 4250 */ 129, 30, 13, 115, 6, 129, 30, 11, 116, 5, /* 4260 */ 129, 30, 8, 117, 4, 129, 30, 5, 117, 4, /* 4270 */ 129, 30, 4, 117, 4, 130, 30, 4, 130, 193, /* 4280 */ 129, 30, 4, 117, 4, 132, 30, 91, 137, 30, /* 4290 */ 4, 117, 4, 132, 30, 4, 144, 30, 5, 130, /* 4300 */ 30, 7, 129, 30, 8, 129, 30, 11, 129, 30, /* 4310 */ 18, 132, 193, 129, 30, 4, 117, 4, 132, 30, /* 4320 */ 91, 132, 30, 4, 103, 18, 129, 30, 4, 97, /* 4330 */ 24, 129, 30, 4, 92, 29, 129, 30, 4, 87, /* 4340 */ 34, 129, 81, 40, 129, 76, 45, 129, 70, 49, /* 4350 */ 129, 65, 49, 129, 60, 49, 129, 55, 49, 129, /* 4360 */ 50, 48, 129, 44, 49, 129, 39, 48, 129, 33, /* 4370 */ 49, 129, 30, 47, 129, 34, 37, 129, 40, 26, /* 4380 */ 129, 46, 19, 129, 52, 19, 129, 58, 19, 129, /* 4390 */ 64, 19, 129, 70, 19, 129, 76, 19, 129, 82, /* 4400 */ 19, 129, 30, 4, 88, 18, 129, 30, 4, 94, /* 4410 */ 18, 129, 30, 4, 100, 18, 129, 30, 4, 106, /* 4420 */ 15, 129, 30, 91, 137, 30, 4, 117, 4, 132, /* 4430 */ 193, 129, 30, 4, 117, 4, 132, 30, 91, 132, /* 4440 */ 30, 4, 107, 14, 129, 30, 4, 104, 17, 129, /* 4450 */ 30, 4, 101, 20, 129, 30, 4, 99, 22, 129, /* 4460 */ 96, 25, 129, 93, 28, 129, 91, 28, 129, 88, /* 4470 */ 29, 129, 85, 29, 129, 82, 29, 129, 79, 29, /* 4480 */ 129, 76, 29, 129, 74, 29, 129, 71, 29, 129, /* 4490 */ 68, 29, 129, 65, 29, 129, 62, 29, 129, 60, /* 4500 */ 29, 129, 57, 29, 129, 54, 29, 129, 51, 29, /* 4510 */ 129, 49, 28, 129, 46, 29, 129, 43, 29, 129, /* 4520 */ 40, 29, 117, 4, 129, 37, 29, 117, 4, 129, /* 4530 */ 35, 29, 117, 4, 129, 32, 29, 117, 4, 129, /* 4540 */ 30, 91, 132, 117, 4, 132, 193, 129, 63, 25, /* 4550 */ 129, 57, 37, 129, 53, 45, 129, 50, 51, 129, /* 4560 */ 47, 57, 129, 45, 61, 129, 43, 65, 129, 41, /* 4570 */ 69, 129, 39, 73, 129, 38, 21, 92, 21, 129, /* 4580 */ 36, 18, 97, 18, 129, 35, 14, 102, 14, 129, /* 4590 */ 34, 11, 106, 11, 129, 33, 10, 108, 10, 129, /* 4600 */ 32, 8, 111, 8, 129, 32, 6, 113, 6, 129, /* 4610 */ 31, 6, 114, 6, 129, 31, 5, 115, 5, 129, /* 4620 */ 30, 5, 116, 5, 130, 30, 4, 117, 4, 132, /* 4630 */ 30, 5, 116, 5, 130, 31, 5, 115, 5, 129, /* 4640 */ 31, 6, 114, 6, 129, 32, 6, 113, 6, 129, /* 4650 */ 32, 8, 111, 8, 129, 33, 10, 108, 10, 129, /* 4660 */ 34, 11, 106, 11, 129, 35, 14, 102, 14, 129, /* 4670 */ 36, 18, 97, 18, 129, 38, 21, 92, 21, 129, /* 4680 */ 39, 73, 129, 41, 69, 129, 43, 65, 129, 45, /* 4690 */ 61, 129, 47, 57, 129, 50, 51, 129, 53, 45, /* 4700 */ 129, 57, 37, 129, 63, 25, 129, 193, 129, 30, /* 4710 */ 4, 117, 4, 132, 30, 91, 137, 30, 4, 80, /* 4720 */ 4, 117, 4, 132, 80, 4, 117, 4, 134, 80, /* 4730 */ 5, 116, 5, 131, 80, 6, 115, 6, 130, 81, /* 4740 */ 6, 114, 6, 129, 81, 8, 112, 8, 129, 81, /* 4750 */ 9, 111, 9, 129, 82, 10, 109, 10, 129, 82, /* 4760 */ 13, 106, 13, 129, 83, 35, 129, 84, 33, 129, /* 4770 */ 85, 31, 129, 86, 29, 129, 88, 25, 129, 90, /* 4780 */ 21, 129, 93, 15, 129, 96, 9, 129, 193, 129, /* 4790 */ 63, 25, 129, 57, 37, 129, 53, 45, 129, 50, /* 4800 */ 51, 129, 47, 57, 129, 45, 61, 129, 43, 65, /* 4810 */ 129, 41, 69, 129, 39, 73, 129, 38, 21, 92, /* 4820 */ 21, 129, 36, 18, 97, 18, 129, 35, 14, 102, /* 4830 */ 14, 129, 34, 11, 106, 11, 129, 33, 10, 108, /* 4840 */ 10, 129, 32, 8, 111, 8, 129, 32, 6, 113, /* 4850 */ 6, 129, 31, 6, 114, 6, 129, 31, 5, 115, /* 4860 */ 5, 129, 30, 5, 116, 5, 130, 30, 4, 39, /* 4870 */ 2, 117, 4, 129, 30, 4, 40, 4, 117, 4, /* 4880 */ 129, 30, 4, 41, 5, 117, 4, 129, 30, 4, /* 4890 */ 41, 6, 117, 4, 129, 30, 5, 40, 8, 116, /* 4900 */ 5, 129, 30, 5, 39, 10, 116, 5, 129, 31, /* 4910 */ 5, 38, 11, 115, 5, 129, 31, 18, 114, 6, /* 4920 */ 129, 32, 17, 113, 6, 129, 32, 16, 111, 8, /* 4930 */ 129, 33, 15, 108, 10, 129, 33, 14, 106, 11, /* 4940 */ 129, 32, 17, 102, 14, 129, 31, 23, 97, 18, /* 4950 */ 129, 31, 28, 92, 21, 129, 30, 82, 129, 30, /* 4960 */ 80, 129, 30, 11, 43, 65, 129, 30, 10, 45, /* 4970 */ 61, 129, 31, 8, 47, 57, 129, 32, 6, 50, /* 4980 */ 51, 129, 33, 5, 53, 45, 129, 35, 4, 57, /* 4990 */ 37, 129, 38, 2, 63, 25, 129, 193, 129, 30, /* 5000 */ 4, 117, 4, 132, 30, 91, 137, 30, 4, 76, /* 5010 */ 8, 117, 4, 129, 30, 4, 73, 11, 117, 4, /* 5020 */ 129, 30, 4, 70, 14, 117, 4, 129, 30, 4, /* 5030 */ 67, 17, 117, 4, 129, 65, 19, 117, 4, 129, /* 5040 */ 62, 22, 117, 4, 129, 59, 25, 117, 4, 129, /* 5050 */ 56, 28, 117, 4, 129, 53, 31, 117, 4, 129, /* 5060 */ 50, 34, 117, 4, 129, 47, 29, 80, 5, 116, /* 5070 */ 5, 129, 30, 4, 45, 29, 80, 5, 116, 5, /* 5080 */ 129, 30, 4, 42, 29, 80, 5, 116, 5, 129, /* 5090 */ 30, 4, 39, 30, 80, 6, 115, 6, 129, 30, /* 5100 */ 4, 36, 30, 80, 6, 115, 6, 129, 30, 33, /* 5110 */ 81, 6, 114, 6, 129, 30, 30, 81, 8, 112, /* 5120 */ 8, 129, 30, 27, 81, 9, 111, 9, 129, 30, /* 5130 */ 25, 82, 10, 109, 10, 129, 30, 22, 82, 13, /* 5140 */ 106, 13, 129, 30, 19, 83, 35, 129, 30, 16, /* 5150 */ 84, 33, 129, 30, 13, 85, 31, 129, 30, 11, /* 5160 */ 86, 29, 129, 30, 8, 88, 25, 129, 30, 5, /* 5170 */ 90, 21, 129, 30, 4, 93, 15, 129, 30, 4, /* 5180 */ 96, 9, 129, 30, 4, 130, 193, 129, 30, 18, /* 5190 */ 130, 30, 18, 89, 15, 129, 30, 18, 85, 23, /* 5200 */ 129, 34, 11, 83, 27, 129, 34, 9, 81, 31, /* 5210 */ 129, 33, 8, 79, 35, 129, 33, 6, 78, 16, /* 5220 */ 106, 9, 129, 32, 6, 77, 15, 109, 7, 129, /* 5230 */ 32, 5, 76, 14, 111, 6, 129, 31, 5, 75, /* 5240 */ 14, 113, 5, 129, 31, 4, 74, 15, 114, 5, /* 5250 */ 129, 31, 4, 74, 14, 115, 4, 129, 30, 4, /* 5260 */ 73, 15, 116, 4, 129, 30, 4, 73, 14, 116, /* 5270 */ 4, 129, 30, 4, 73, 14, 117, 4, 129, 30, /* 5280 */ 4, 72, 15, 117, 4, 130, 30, 4, 71, 15, /* 5290 */ 117, 4, 130, 30, 4, 70, 15, 117, 4, 129, /* 5300 */ 30, 5, 70, 15, 117, 4, 129, 30, 5, 69, /* 5310 */ 15, 116, 5, 129, 30, 6, 68, 16, 115, 5, /* 5320 */ 129, 31, 6, 67, 16, 114, 6, 129, 31, 7, /* 5330 */ 66, 17, 113, 6, 129, 32, 7, 64, 18, 111, /* 5340 */ 8, 129, 32, 8, 62, 19, 109, 9, 129, 33, /* 5350 */ 9, 60, 20, 107, 10, 129, 34, 11, 57, 22, /* 5360 */ 103, 13, 129, 35, 43, 103, 18, 129, 36, 41, /* 5370 */ 103, 18, 129, 38, 38, 103, 18, 129, 39, 35, /* 5380 */ 103, 18, 129, 41, 31, 129, 43, 27, 129, 46, /* 5390 */ 22, 129, 49, 14, 129, 193, 129, 103, 18, 132, /* 5400 */ 110, 11, 129, 113, 8, 129, 114, 7, 129, 116, /* 5410 */ 5, 130, 117, 4, 132, 30, 4, 117, 4, 132, /* 5420 */ 30, 91, 137, 30, 4, 117, 4, 132, 117, 4, /* 5430 */ 132, 116, 5, 130, 114, 7, 129, 113, 8, 129, /* 5440 */ 110, 11, 129, 103, 18, 132, 193, 129, 117, 4, /* 5450 */ 132, 56, 65, 129, 50, 71, 129, 46, 75, 129, /* 5460 */ 44, 77, 129, 42, 79, 129, 40, 81, 129, 38, /* 5470 */ 83, 129, 36, 85, 129, 35, 86, 129, 34, 20, /* 5480 */ 117, 4, 129, 33, 17, 117, 4, 129, 32, 15, /* 5490 */ 117, 4, 129, 32, 13, 117, 4, 129, 31, 12, /* 5500 */ 129, 31, 10, 129, 31, 9, 129, 30, 9, 129, /* 5510 */ 30, 8, 130, 30, 7, 132, 31, 6, 130, 31, /* 5520 */ 7, 129, 32, 6, 129, 32, 7, 129, 33, 7, /* 5530 */ 129, 34, 7, 129, 35, 8, 129, 36, 9, 117, /* 5540 */ 4, 129, 38, 9, 117, 4, 129, 40, 10, 117, /* 5550 */ 4, 129, 42, 12, 117, 4, 129, 44, 77, 129, /* 5560 */ 46, 75, 129, 50, 71, 129, 56, 43, 100, 21, /* 5570 */ 129, 117, 4, 132, 193, 129, 117, 4, 132, 115, /* 5580 */ 6, 129, 110, 11, 129, 105, 16, 129, 101, 20, /* 5590 */ 129, 96, 25, 129, 92, 29, 129, 87, 34, 129, /* 5600 */ 83, 38, 129, 78, 43, 129, 74, 47, 129, 70, /* 5610 */ 42, 117, 4, 129, 65, 42, 117, 4, 129, 60, /* 5620 */ 43, 117, 4, 129, 56, 42, 129, 51, 42, 129, /* 5630 */ 46, 43, 129, 42, 43, 129, 37, 44, 129, 33, /* 5640 */ 43, 129, 30, 42, 129, 33, 34, 129, 38, 25, /* 5650 */ 129, 42, 16, 129, 47, 15, 129, 52, 15, 129, /* 5660 */ 57, 15, 129, 61, 16, 129, 66, 16, 129, 71, /* 5670 */ 16, 129, 76, 16, 129, 80, 16, 129, 85, 16, /* 5680 */ 117, 4, 129, 90, 16, 117, 4, 129, 95, 16, /* 5690 */ 117, 4, 129, 100, 21, 129, 105, 16, 129, 110, /* 5700 */ 11, 129, 114, 7, 129, 117, 4, 132, 193, 129, /* 5710 */ 117, 4, 132, 115, 6, 129, 110, 11, 129, 105, /* 5720 */ 16, 129, 101, 20, 129, 96, 25, 129, 92, 29, /* 5730 */ 129, 87, 34, 129, 83, 38, 129, 78, 43, 129, /* 5740 */ 74, 47, 129, 70, 42, 117, 4, 129, 65, 42, /* 5750 */ 117, 4, 129, 60, 43, 117, 4, 129, 56, 42, /* 5760 */ 129, 51, 42, 129, 46, 43, 129, 42, 43, 129, /* 5770 */ 37, 44, 129, 33, 43, 129, 30, 42, 129, 33, /* 5780 */ 34, 129, 38, 25, 129, 42, 16, 129, 47, 15, /* 5790 */ 129, 52, 15, 129, 57, 15, 129, 61, 16, 129, /* 5800 */ 65, 17, 129, 60, 27, 129, 56, 36, 129, 51, /* 5810 */ 42, 129, 46, 43, 129, 42, 43, 129, 37, 44, /* 5820 */ 129, 33, 43, 129, 30, 42, 129, 33, 34, 129, /* 5830 */ 38, 25, 129, 42, 16, 129, 47, 15, 129, 52, /* 5840 */ 15, 129, 57, 15, 129, 61, 16, 129, 66, 16, /* 5850 */ 129, 71, 16, 129, 76, 16, 129, 80, 16, 129, /* 5860 */ 85, 16, 117, 4, 129, 90, 16, 117, 4, 129, /* 5870 */ 95, 16, 117, 4, 129, 100, 21, 129, 105, 16, /* 5880 */ 129, 110, 11, 129, 114, 7, 129, 117, 4, 132, /* 5890 */ 193, 129, 30, 4, 117, 4, 132, 30, 4, 115, /* 5900 */ 6, 129, 30, 4, 112, 9, 129, 30, 6, 109, /* 5910 */ 12, 129, 30, 9, 106, 15, 129, 30, 11, 103, /* 5920 */ 18, 129, 30, 14, 100, 21, 129, 30, 4, 38, /* 5930 */ 9, 98, 23, 129, 30, 4, 40, 10, 95, 26, /* 5940 */ 129, 30, 4, 43, 9, 92, 29, 129, 46, 9, /* 5950 */ 89, 32, 129, 49, 8, 86, 28, 117, 4, 129, /* 5960 */ 51, 9, 83, 28, 117, 4, 129, 54, 9, 80, /* 5970 */ 28, 117, 4, 129, 57, 8, 77, 28, 117, 4, /* 5980 */ 129, 59, 9, 74, 28, 129, 62, 37, 129, 64, /* 5990 */ 33, 129, 66, 28, 129, 63, 28, 129, 60, 28, /* 6000 */ 129, 57, 28, 129, 54, 33, 129, 51, 39, 129, /* 6010 */ 48, 29, 83, 9, 129, 30, 4, 45, 29, 86, /* 6020 */ 9, 129, 30, 4, 42, 29, 89, 9, 129, 30, /* 6030 */ 4, 39, 29, 92, 8, 129, 30, 4, 36, 29, /* 6040 */ 94, 9, 129, 30, 32, 97, 9, 129, 30, 29, /* 6050 */ 100, 8, 117, 4, 129, 30, 26, 103, 8, 117, /* 6060 */ 4, 129, 30, 23, 105, 9, 117, 4, 129, 30, /* 6070 */ 20, 108, 13, 129, 30, 18, 111, 10, 129, 30, /* 6080 */ 15, 113, 8, 129, 30, 12, 116, 5, 129, 30, /* 6090 */ 9, 117, 4, 129, 30, 6, 117, 4, 129, 30, /* 6100 */ 4, 117, 4, 132, 193, 129, 117, 4, 132, 114, /* 6110 */ 7, 129, 111, 10, 129, 108, 13, 129, 105, 16, /* 6120 */ 129, 102, 19, 129, 100, 21, 129, 96, 25, 129, /* 6130 */ 93, 28, 129, 90, 31, 129, 87, 34, 129, 84, /* 6140 */ 30, 117, 4, 129, 30, 4, 81, 30, 117, 4, /* 6150 */ 129, 30, 4, 78, 30, 117, 4, 129, 30, 4, /* 6160 */ 75, 30, 117, 4, 129, 30, 4, 72, 30, 129, /* 6170 */ 30, 69, 129, 30, 66, 129, 30, 63, 129, 30, /* 6180 */ 60, 129, 30, 57, 129, 30, 54, 129, 30, 51, /* 6190 */ 129, 30, 48, 129, 30, 51, 129, 30, 4, 73, /* 6200 */ 12, 129, 30, 4, 76, 12, 129, 30, 4, 80, /* 6210 */ 12, 129, 30, 4, 83, 12, 129, 87, 12, 129, /* 6220 */ 90, 12, 117, 4, 129, 94, 11, 117, 4, 129, /* 6230 */ 97, 12, 117, 4, 129, 101, 12, 117, 4, 129, /* 6240 */ 104, 17, 129, 108, 13, 129, 111, 10, 129, 115, /* 6250 */ 6, 129, 117, 4, 134, 193, 129, 30, 1, 103, /* 6260 */ 18, 129, 30, 4, 103, 18, 129, 30, 7, 103, /* 6270 */ 18, 129, 30, 9, 103, 18, 129, 30, 12, 110, /* 6280 */ 11, 129, 30, 15, 113, 8, 129, 30, 18, 114, /* 6290 */ 7, 129, 30, 21, 116, 5, 129, 30, 24, 116, /* 6300 */ 5, 129, 30, 27, 117, 4, 129, 30, 30, 117, /* 6310 */ 4, 129, 30, 33, 117, 4, 129, 30, 4, 37, /* 6320 */ 28, 117, 4, 129, 30, 4, 40, 28, 117, 4, /* 6330 */ 129, 30, 4, 42, 29, 117, 4, 129, 30, 4, /* 6340 */ 45, 29, 117, 4, 129, 30, 4, 48, 29, 117, /* 6350 */ 4, 129, 30, 4, 51, 29, 117, 4, 129, 30, /* 6360 */ 4, 54, 29, 117, 4, 129, 30, 4, 57, 29, /* 6370 */ 117, 4, 129, 30, 4, 59, 30, 117, 4, 129, /* 6380 */ 30, 4, 62, 30, 117, 4, 129, 30, 4, 65, /* 6390 */ 30, 117, 4, 129, 30, 4, 68, 30, 117, 4, /* 6400 */ 129, 30, 4, 71, 30, 117, 4, 129, 30, 4, /* 6410 */ 74, 30, 117, 4, 129, 30, 4, 77, 30, 117, /* 6420 */ 4, 129, 30, 4, 80, 30, 117, 4, 129, 30, /* 6430 */ 4, 83, 30, 117, 4, 129, 30, 4, 86, 35, /* 6440 */ 129, 30, 4, 89, 32, 129, 30, 4, 91, 30, /* 6450 */ 129, 30, 4, 94, 27, 129, 30, 5, 97, 24, /* 6460 */ 129, 30, 5, 100, 21, 129, 30, 7, 103, 18, /* 6470 */ 129, 30, 8, 106, 15, 129, 30, 11, 109, 12, /* 6480 */ 129, 30, 18, 112, 9, 129, 30, 18, 115, 6, /* 6490 */ 129, 30, 18, 117, 4, 129, 30, 18, 120, 1, /* 6500 */ 129, 193, 129, 42, 8, 129, 38, 16, 129, 36, /* 6510 */ 20, 129, 34, 24, 71, 5, 129, 33, 26, 69, /* 6520 */ 10, 129, 32, 28, 68, 13, 129, 31, 30, 68, /* 6530 */ 14, 129, 31, 9, 52, 9, 68, 15, 129, 30, /* 6540 */ 8, 54, 8, 69, 14, 129, 30, 7, 55, 7, /* 6550 */ 71, 4, 78, 6, 129, 30, 6, 56, 6, 79, /* 6560 */ 5, 129, 30, 6, 56, 6, 80, 4, 130, 31, /* 6570 */ 5, 56, 5, 80, 4, 129, 31, 5, 56, 5, /* 6580 */ 79, 5, 129, 32, 5, 55, 5, 78, 6, 129, /* 6590 */ 33, 5, 54, 5, 77, 7, 129, 34, 6, 52, /* 6600 */ 6, 74, 9, 129, 35, 48, 129, 33, 49, 129, /* 6610 */ 32, 49, 129, 31, 49, 129, 30, 49, 129, 30, /* 6620 */ 47, 129, 30, 45, 129, 30, 41, 129, 30, 6, /* 6630 */ 129, 30, 4, 129, 30, 3, 129, 30, 2, 129, /* 6640 */ 193, 129, 30, 4, 117, 4, 130, 31, 90, 136, /* 6650 */ 37, 5, 72, 5, 129, 35, 5, 74, 5, 129, /* 6660 */ 33, 5, 76, 5, 129, 32, 5, 77, 5, 129, /* 6670 */ 31, 5, 78, 5, 129, 31, 4, 79, 4, 129, /* 6680 */ 30, 5, 79, 5, 131, 30, 6, 78, 6, 129, /* 6690 */ 30, 7, 77, 7, 129, 31, 8, 75, 8, 129, /* 6700 */ 31, 11, 72, 11, 129, 32, 15, 67, 15, 129, /* 6710 */ 33, 48, 129, 34, 46, 129, 35, 44, 129, 37, /* 6720 */ 40, 129, 39, 36, 129, 42, 30, 129, 46, 22, /* 6730 */ 129, 193, 129, 48, 18, 129, 43, 28, 129, 41, /* 6740 */ 32, 129, 39, 36, 129, 37, 40, 129, 35, 44, /* 6750 */ 129, 34, 46, 129, 33, 13, 68, 13, 129, 32, /* 6760 */ 9, 73, 9, 129, 32, 7, 75, 7, 129, 31, /* 6770 */ 6, 77, 6, 129, 31, 5, 78, 5, 129, 30, /* 6780 */ 5, 79, 5, 129, 30, 4, 80, 4, 133, 31, /* 6790 */ 3, 79, 4, 129, 31, 4, 79, 4, 129, 32, /* 6800 */ 3, 78, 4, 129, 32, 4, 76, 6, 129, 33, /* 6810 */ 4, 74, 7, 129, 34, 4, 72, 8, 129, 35, /* 6820 */ 5, 72, 7, 129, 37, 5, 73, 4, 129, 39, /* 6830 */ 4, 74, 1, 129, 129, 193, 129, 46, 22, 129, /* 6840 */ 42, 30, 129, 39, 36, 129, 37, 40, 129, 35, /* 6850 */ 44, 129, 34, 46, 129, 33, 48, 129, 32, 15, /* 6860 */ 67, 15, 129, 31, 11, 72, 11, 129, 31, 8, /* 6870 */ 75, 8, 129, 30, 7, 77, 7, 129, 30, 6, /* 6880 */ 78, 6, 129, 30, 5, 79, 5, 131, 31, 4, /* 6890 */ 79, 4, 129, 31, 5, 78, 5, 129, 32, 5, /* 6900 */ 77, 5, 129, 33, 5, 76, 5, 129, 35, 5, /* 6910 */ 74, 5, 117, 4, 129, 37, 5, 72, 5, 117, /* 6920 */ 4, 129, 30, 91, 136, 30, 4, 130, 193, 129, /* 6930 */ 48, 18, 129, 43, 28, 129, 41, 32, 129, 39, /* 6940 */ 36, 129, 37, 40, 129, 35, 44, 129, 34, 46, /* 6950 */ 129, 33, 13, 55, 4, 68, 13, 129, 32, 9, /* 6960 */ 55, 4, 73, 9, 129, 32, 7, 55, 4, 75, /* 6970 */ 7, 129, 31, 6, 55, 4, 77, 6, 129, 31, /* 6980 */ 5, 55, 4, 78, 5, 129, 30, 5, 55, 4, /* 6990 */ 79, 5, 129, 30, 4, 55, 4, 80, 4, 132, /* 7000 */ 30, 4, 55, 4, 79, 5, 129, 31, 3, 55, /* 7010 */ 4, 78, 5, 129, 31, 4, 55, 4, 77, 6, /* 7020 */ 129, 32, 3, 55, 4, 75, 7, 129, 32, 4, /* 7030 */ 55, 4, 73, 9, 129, 33, 4, 55, 4, 68, /* 7040 */ 13, 129, 34, 4, 55, 25, 129, 35, 5, 55, /* 7050 */ 24, 129, 37, 5, 55, 22, 129, 39, 4, 55, /* 7060 */ 20, 129, 55, 18, 129, 55, 16, 129, 55, 11, /* 7070 */ 129, 193, 129, 80, 4, 129, 30, 4, 80, 4, /* 7080 */ 130, 30, 78, 129, 30, 82, 129, 30, 85, 129, /* 7090 */ 30, 87, 129, 30, 88, 129, 30, 89, 129, 30, /* 7100 */ 90, 130, 30, 4, 80, 4, 115, 6, 129, 30, /* 7110 */ 4, 80, 4, 117, 4, 129, 80, 4, 105, 6, /* 7120 */ 117, 4, 129, 80, 4, 103, 10, 116, 5, 129, /* 7130 */ 80, 4, 102, 19, 129, 80, 4, 101, 19, 129, /* 7140 */ 101, 19, 129, 101, 18, 129, 102, 16, 129, 103, /* 7150 */ 12, 129, 105, 6, 129, 193, 129, 12, 10, 59, /* 7160 */ 11, 129, 9, 16, 55, 19, 129, 7, 20, 53, /* 7170 */ 23, 129, 6, 7, 23, 5, 32, 6, 51, 27, /* 7180 */ 129, 4, 7, 25, 16, 50, 29, 129, 3, 6, /* 7190 */ 27, 16, 49, 31, 129, 2, 6, 28, 16, 48, /* 7200 */ 33, 129, 1, 6, 27, 18, 47, 35, 129, 1, /* 7210 */ 6, 27, 31, 71, 12, 129, 1, 5, 26, 15, /* 7220 */ 44, 10, 75, 8, 129, 1, 5, 25, 14, 45, /* 7230 */ 7, 77, 7, 129, 1, 5, 25, 13, 45, 5, /* 7240 */ 79, 5, 129, 1, 5, 24, 14, 45, 4, 80, /* 7250 */ 4, 129, 1, 5, 24, 13, 45, 4, 80, 4, /* 7260 */ 129, 1, 5, 23, 14, 45, 4, 80, 4, 129, /* 7270 */ 1, 5, 23, 13, 45, 4, 80, 4, 129, 1, /* 7280 */ 6, 22, 13, 45, 5, 79, 5, 129, 1, 6, /* 7290 */ 21, 14, 45, 7, 77, 7, 129, 1, 7, 21, /* 7300 */ 13, 46, 8, 75, 8, 129, 1, 8, 20, 13, /* 7310 */ 46, 12, 71, 12, 129, 1, 10, 18, 15, 47, /* 7320 */ 35, 129, 2, 30, 48, 33, 129, 3, 29, 49, /* 7330 */ 32, 129, 4, 27, 50, 31, 129, 5, 25, 51, /* 7340 */ 27, 80, 2, 86, 4, 129, 7, 21, 53, 23, /* 7350 */ 80, 3, 85, 6, 129, 9, 17, 55, 19, 80, /* 7360 */ 12, 129, 12, 12, 59, 11, 81, 11, 129, 82, /* 7370 */ 10, 129, 84, 7, 129, 86, 4, 129, 193, 129, /* 7380 */ 30, 4, 117, 4, 130, 30, 91, 136, 30, 4, /* 7390 */ 72, 5, 129, 30, 4, 74, 5, 129, 75, 5, /* 7400 */ 129, 76, 5, 129, 76, 6, 129, 77, 6, 130, /* 7410 */ 77, 7, 130, 76, 8, 129, 30, 4, 75, 9, /* 7420 */ 129, 30, 4, 72, 12, 129, 30, 54, 129, 30, /* 7430 */ 53, 130, 30, 52, 129, 30, 51, 129, 30, 49, /* 7440 */ 129, 30, 46, 129, 30, 42, 129, 30, 4, 130, /* 7450 */ 193, 129, 30, 4, 80, 4, 129, 30, 4, 80, /* 7460 */ 4, 100, 6, 129, 30, 54, 98, 10, 129, 30, /* 7470 */ 54, 97, 12, 129, 30, 54, 96, 14, 131, 30, /* 7480 */ 54, 97, 12, 129, 30, 54, 98, 10, 129, 30, /* 7490 */ 54, 100, 6, 129, 30, 4, 130, 193, 129, 7, /* 7500 */ 6, 129, 4, 11, 129, 3, 13, 129, 2, 14, /* 7510 */ 129, 1, 15, 130, 1, 3, 6, 9, 129, 1, /* 7520 */ 3, 7, 6, 129, 1, 3, 130, 1, 4, 129, /* 7530 */ 1, 5, 80, 4, 129, 1, 7, 80, 4, 100, /* 7540 */ 6, 129, 2, 82, 98, 10, 129, 3, 81, 97, /* 7550 */ 12, 129, 4, 80, 96, 14, 129, 5, 79, 96, /* 7560 */ 14, 129, 7, 77, 96, 14, 129, 10, 74, 97, /* 7570 */ 12, 129, 14, 70, 98, 10, 129, 19, 65, 100, /* 7580 */ 6, 129, 193, 129, 30, 4, 117, 4, 130, 30, /* 7590 */ 91, 136, 30, 4, 57, 9, 129, 30, 4, 55, /* 7600 */ 12, 129, 52, 17, 129, 50, 20, 129, 48, 24, /* 7610 */ 129, 46, 27, 129, 44, 21, 69, 6, 129, 41, /* 7620 */ 22, 70, 6, 80, 4, 129, 30, 4, 39, 21, /* 7630 */ 72, 6, 80, 4, 129, 30, 4, 36, 22, 73, /* 7640 */ 11, 129, 30, 26, 75, 9, 129, 30, 23, 76, /* 7650 */ 8, 129, 30, 21, 78, 6, 129, 30, 19, 79, /* 7660 */ 5, 129, 30, 16, 80, 4, 129, 30, 14, 80, /* 7670 */ 4, 129, 30, 12, 129, 30, 10, 129, 30, 7, /* 7680 */ 129, 30, 5, 129, 30, 4, 130, 193, 129, 30, /* 7690 */ 4, 117, 4, 130, 30, 91, 136, 30, 4, 130, /* 7700 */ 193, 129, 30, 4, 80, 4, 130, 30, 54, 136, /* 7710 */ 30, 4, 72, 5, 129, 30, 4, 74, 5, 129, /* 7720 */ 75, 5, 129, 76, 5, 129, 30, 4, 75, 7, /* 7730 */ 129, 30, 4, 74, 9, 129, 30, 54, 132, 30, /* 7740 */ 53, 129, 30, 52, 129, 30, 51, 129, 30, 48, /* 7750 */ 129, 30, 4, 72, 5, 129, 30, 4, 74, 5, /* 7760 */ 129, 75, 5, 129, 76, 5, 129, 30, 4, 75, /* 7770 */ 7, 129, 30, 4, 74, 9, 129, 30, 54, 132, /* 7780 */ 30, 53, 129, 30, 52, 129, 30, 51, 129, 30, /* 7790 */ 48, 129, 30, 4, 130, 193, 129, 30, 4, 80, /* 7800 */ 4, 130, 30, 54, 136, 30, 4, 72, 5, 129, /* 7810 */ 30, 4, 74, 5, 129, 75, 5, 129, 76, 5, /* 7820 */ 129, 76, 6, 129, 77, 6, 130, 77, 7, 130, /* 7830 */ 76, 8, 129, 30, 4, 75, 9, 129, 30, 4, /* 7840 */ 72, 12, 129, 30, 54, 129, 30, 53, 130, 30, /* 7850 */ 52, 129, 30, 51, 129, 30, 49, 129, 30, 46, /* 7860 */ 129, 30, 42, 129, 30, 4, 130, 193, 129, 48, /* 7870 */ 18, 129, 43, 28, 129, 41, 32, 129, 39, 36, /* 7880 */ 129, 37, 40, 129, 35, 44, 129, 34, 46, 129, /* 7890 */ 33, 13, 68, 13, 129, 32, 9, 73, 9, 129, /* 7900 */ 32, 7, 75, 7, 129, 31, 6, 77, 6, 129, /* 7910 */ 31, 5, 78, 5, 129, 30, 5, 79, 5, 129, /* 7920 */ 30, 4, 80, 4, 132, 30, 5, 79, 5, 130, /* 7930 */ 31, 5, 78, 5, 129, 31, 6, 77, 6, 129, /* 7940 */ 32, 7, 75, 7, 129, 32, 9, 73, 9, 129, /* 7950 */ 33, 13, 68, 13, 129, 34, 46, 129, 35, 44, /* 7960 */ 129, 37, 40, 129, 39, 36, 129, 41, 32, 129, /* 7970 */ 43, 28, 129, 48, 18, 129, 193, 129, 1, 3, /* 7980 */ 80, 4, 130, 1, 83, 137, 37, 5, 72, 5, /* 7990 */ 129, 35, 5, 74, 5, 129, 33, 5, 76, 5, /* 8000 */ 129, 32, 5, 77, 5, 129, 31, 5, 78, 5, /* 8010 */ 129, 31, 4, 79, 4, 129, 30, 5, 79, 5, /* 8020 */ 131, 30, 6, 78, 6, 129, 30, 7, 77, 7, /* 8030 */ 129, 31, 8, 75, 8, 129, 31, 11, 72, 11, /* 8040 */ 129, 32, 15, 67, 15, 129, 33, 48, 129, 34, /* 8050 */ 46, 129, 35, 44, 129, 37, 40, 129, 39, 36, /* 8060 */ 129, 42, 30, 129, 46, 22, 129, 193, 129, 46, /* 8070 */ 22, 129, 42, 30, 129, 39, 36, 129, 37, 40, /* 8080 */ 129, 35, 44, 129, 34, 46, 129, 33, 48, 129, /* 8090 */ 32, 15, 67, 15, 129, 31, 11, 72, 11, 129, /* 8100 */ 31, 8, 75, 8, 129, 30, 7, 77, 7, 129, /* 8110 */ 30, 6, 78, 6, 129, 30, 5, 79, 5, 131, /* 8120 */ 31, 4, 79, 4, 129, 31, 5, 78, 5, 129, /* 8130 */ 32, 5, 77, 5, 129, 33, 5, 76, 5, 129, /* 8140 */ 35, 5, 74, 5, 129, 37, 5, 72, 5, 129, /* 8150 */ 1, 83, 136, 1, 3, 80, 4, 130, 193, 129, /* 8160 */ 30, 4, 80, 4, 130, 30, 54, 136, 30, 4, /* 8170 */ 68, 6, 129, 30, 4, 70, 6, 129, 71, 7, /* 8180 */ 129, 72, 7, 129, 73, 7, 129, 74, 7, 129, /* 8190 */ 74, 8, 129, 75, 8, 130, 69, 15, 129, 67, /* 8200 */ 17, 129, 66, 18, 129, 65, 19, 130, 65, 18, /* 8210 */ 130, 66, 16, 129, 67, 13, 129, 69, 8, 129, /* 8220 */ 193, 129, 30, 13, 64, 8, 129, 30, 13, 61, /* 8230 */ 14, 129, 30, 13, 59, 18, 129, 30, 13, 57, /* 8240 */ 22, 129, 33, 8, 56, 24, 129, 32, 7, 55, /* 8250 */ 26, 129, 32, 6, 54, 28, 129, 31, 6, 53, /* 8260 */ 16, 77, 6, 129, 31, 5, 53, 14, 79, 4, /* 8270 */ 129, 30, 5, 52, 14, 80, 4, 129, 30, 5, /* 8280 */ 52, 13, 80, 4, 129, 30, 4, 52, 13, 80, /* 8290 */ 4, 129, 30, 4, 52, 12, 80, 4, 129, 30, /* 8300 */ 4, 51, 13, 80, 4, 130, 30, 4, 50, 13, /* 8310 */ 79, 5, 129, 30, 4, 50, 13, 78, 5, 129, /* 8320 */ 30, 5, 49, 14, 77, 6, 129, 31, 4, 49, /* 8330 */ 13, 76, 6, 129, 31, 5, 48, 14, 75, 7, /* 8340 */ 129, 32, 5, 47, 14, 73, 8, 129, 32, 6, /* 8350 */ 45, 16, 71, 13, 129, 33, 27, 71, 13, 129, /* 8360 */ 34, 26, 71, 13, 129, 35, 24, 71, 13, 129, /* 8370 */ 37, 20, 129, 39, 16, 129, 43, 9, 129, 193, /* 8380 */ 129, 80, 4, 131, 41, 56, 129, 37, 60, 129, /* 8390 */ 35, 62, 129, 33, 64, 129, 32, 65, 129, 31, /* 8400 */ 66, 129, 30, 67, 130, 30, 11, 80, 4, 129, /* 8410 */ 30, 9, 80, 4, 129, 30, 8, 80, 4, 129, /* 8420 */ 31, 7, 80, 4, 129, 31, 6, 129, 32, 5, /* 8430 */ 129, 33, 5, 129, 35, 4, 129, 38, 3, 129, /* 8440 */ 193, 129, 80, 4, 130, 42, 42, 129, 38, 46, /* 8450 */ 129, 35, 49, 129, 33, 51, 129, 32, 52, 129, /* 8460 */ 31, 53, 130, 30, 54, 129, 30, 12, 129, 30, /* 8470 */ 9, 129, 30, 8, 129, 30, 7, 130, 31, 6, /* 8480 */ 130, 32, 6, 129, 33, 5, 129, 34, 5, 129, /* 8490 */ 35, 5, 80, 4, 129, 37, 5, 80, 4, 129, /* 8500 */ 30, 54, 136, 30, 4, 130, 193, 129, 80, 4, /* 8510 */ 130, 77, 7, 129, 74, 10, 129, 70, 14, 129, /* 8520 */ 66, 18, 129, 62, 22, 129, 59, 25, 129, 55, /* 8530 */ 29, 129, 51, 33, 129, 47, 37, 129, 44, 32, /* 8540 */ 80, 4, 129, 40, 32, 80, 4, 129, 36, 32, /* 8550 */ 129, 32, 33, 129, 30, 31, 129, 33, 24, 129, /* 8560 */ 36, 17, 129, 40, 12, 129, 44, 12, 129, 48, /* 8570 */ 12, 129, 51, 13, 129, 55, 13, 129, 59, 13, /* 8580 */ 80, 4, 129, 63, 13, 80, 4, 129, 67, 17, /* 8590 */ 129, 71, 13, 129, 74, 10, 129, 78, 6, 129, /* 8600 */ 80, 4, 131, 193, 129, 80, 4, 130, 77, 7, /* 8610 */ 129, 74, 10, 129, 70, 14, 129, 66, 18, 129, /* 8620 */ 62, 22, 129, 59, 25, 129, 55, 29, 129, 51, /* 8630 */ 33, 129, 47, 37, 129, 44, 32, 80, 4, 129, /* 8640 */ 40, 32, 80, 4, 129, 36, 32, 129, 32, 33, /* 8650 */ 129, 30, 31, 129, 33, 24, 129, 36, 17, 129, /* 8660 */ 40, 12, 129, 44, 12, 129, 47, 13, 129, 44, /* 8670 */ 20, 129, 40, 28, 129, 36, 31, 129, 32, 32, /* 8680 */ 129, 30, 30, 129, 33, 24, 129, 36, 17, 129, /* 8690 */ 40, 12, 129, 44, 12, 129, 48, 12, 129, 51, /* 8700 */ 13, 129, 55, 13, 129, 59, 13, 80, 4, 129, /* 8710 */ 63, 13, 80, 4, 129, 67, 17, 129, 71, 13, /* 8720 */ 129, 74, 10, 129, 78, 6, 129, 80, 4, 131, /* 8730 */ 193, 129, 30, 4, 80, 4, 130, 30, 4, 79, /* 8740 */ 5, 129, 30, 5, 77, 7, 129, 30, 6, 74, /* 8750 */ 10, 129, 30, 8, 72, 12, 129, 30, 11, 69, /* 8760 */ 15, 129, 30, 13, 67, 17, 129, 30, 4, 37, /* 8770 */ 8, 64, 20, 129, 30, 4, 39, 8, 62, 22, /* 8780 */ 129, 41, 8, 59, 25, 129, 43, 8, 57, 27, /* 8790 */ 129, 45, 8, 55, 22, 80, 4, 129, 47, 27, /* 8800 */ 80, 4, 129, 49, 23, 129, 47, 22, 129, 44, /* 8810 */ 23, 129, 42, 22, 129, 30, 4, 39, 27, 129, /* 8820 */ 30, 4, 37, 31, 129, 30, 27, 62, 8, 129, /* 8830 */ 30, 25, 64, 8, 129, 30, 22, 66, 8, 80, /* 8840 */ 4, 129, 30, 20, 68, 8, 80, 4, 129, 30, /* 8850 */ 17, 70, 8, 80, 4, 129, 30, 15, 73, 11, /* 8860 */ 129, 30, 12, 75, 9, 129, 30, 10, 77, 7, /* 8870 */ 129, 30, 7, 79, 5, 129, 30, 5, 80, 4, /* 8880 */ 129, 30, 4, 80, 4, 130, 193, 129, 4, 5, /* 8890 */ 80, 4, 129, 2, 9, 80, 4, 129, 1, 11, /* 8900 */ 77, 7, 129, 1, 12, 74, 10, 129, 1, 12, /* 8910 */ 70, 14, 129, 1, 12, 66, 18, 129, 1, 11, /* 8920 */ 62, 22, 129, 2, 9, 59, 25, 129, 4, 11, /* 8930 */ 55, 29, 129, 7, 12, 51, 33, 129, 10, 12, /* 8940 */ 47, 37, 129, 14, 12, 44, 32, 80, 4, 129, /* 8950 */ 17, 13, 40, 32, 80, 4, 129, 21, 13, 36, /* 8960 */ 32, 129, 25, 40, 129, 29, 32, 129, 33, 24, /* 8970 */ 129, 36, 17, 129, 40, 12, 129, 44, 12, 129, /* 8980 */ 48, 12, 129, 51, 13, 129, 55, 13, 129, 59, /* 8990 */ 13, 80, 4, 129, 63, 13, 80, 4, 129, 67, /* 9000 */ 17, 129, 71, 13, 129, 74, 10, 129, 78, 6, /* 9010 */ 129, 80, 4, 131, 193, 129, 30, 1, 71, 13, /* 9020 */ 129, 30, 3, 71, 13, 129, 30, 6, 71, 13, /* 9030 */ 129, 30, 9, 75, 9, 129, 30, 11, 77, 7, /* 9040 */ 129, 30, 14, 79, 5, 129, 30, 17, 79, 5, /* 9050 */ 129, 30, 19, 80, 4, 129, 30, 22, 80, 4, /* 9060 */ 129, 30, 25, 80, 4, 129, 30, 27, 80, 4, /* 9070 */ 129, 30, 4, 36, 24, 80, 4, 129, 30, 4, /* 9080 */ 38, 25, 80, 4, 129, 30, 4, 41, 24, 80, /* 9090 */ 4, 129, 30, 4, 44, 24, 80, 4, 129, 30, /* 9100 */ 4, 46, 25, 80, 4, 129, 30, 4, 49, 25, /* 9110 */ 80, 4, 129, 30, 4, 52, 24, 80, 4, 129, /* 9120 */ 30, 4, 54, 30, 129, 30, 4, 57, 27, 129, /* 9130 */ 30, 4, 59, 25, 129, 30, 4, 62, 22, 129, /* 9140 */ 30, 4, 65, 19, 129, 30, 5, 67, 17, 129, /* 9150 */ 30, 5, 70, 14, 129, 30, 7, 73, 11, 129, /* 9160 */ 30, 9, 76, 8, 129, 30, 13, 78, 6, 129, /* 9170 */ 30, 13, 81, 3, 129, 30, 13, 129, 193, 2, /* 9180 */ 9, 59, 25, 129, 4, 11, 55, 29, 129, 7, /* 9190 */ 12, 51, 33, 129, 10, 12, 47, 37, 129, 14, /* 9200 */ 12, 44, 32, 80, 4, 129, 17, 13, 40, 32, /* 9210 */ 80, 4, 129, 21, 13, 36, 32, 129, 25, 40, /* 9220 */ 129, 29, 32, 129, 33, 24, 129, 36, 17, 129, /* 9230 */ 40, 12, 129, 44, 12, 129, 48, 12, 129, 51, /* 9240 */ 13, 129, 55, 13, 129, 59, 13, 80, 4, 129, /* 9250 */ 63, 13, 80, 4, 129, 67, 17, 129, 71, 13, /* 9260 */ 129, 74, 10, 129, 78, 6, 129, 80, 4, 131, /* 9270 */ 193 }; char line[DWIDTH]; char message[MAXMSG]; char print[DWIDTH]; int debug, i, j, linen, max, nchars, pc, term, trace, x, y; int width = DWIDTH; /* -w option: scrunch letters to 80 columns */ int main(int, char *[]); int main(argc, argv) int argc; char *argv[]; { int ch; /* revoke setgid privileges */ setregid(getgid(), getgid()); while ((ch = getopt(argc, argv, "w:td")) != -1) switch (ch) { case 'd': debug = 1; break; case 't': trace = 1; break; case 'w': width = atoi(optarg); if (width <= 0) errx(1, "illegal argument for -w option"); break; case '?': default: (void)fprintf(stderr, "usage: banner [-w width]\n"); exit(1); } argc -= optind; argv += optind; for (i = 0; i < width; i++) { j = i * 132 / width; print[j] = 1; } /* Have now read in the data. Next get the message to be printed. */ if (*argv) { strcpy(message, *argv); while (*++argv) { strcat(message, " "); strcat(message, *argv); } nchars = strlen(message); } else { if (isatty(fileno(stdin))) fprintf(stderr,"Message: "); (void)fgets(message, sizeof(message), stdin); nchars = strlen(message); message[nchars--] = '\0'; /* get rid of newline */ } /* some debugging print statements */ if (debug) { printf("int asc_ptr[128] = {\n"); for (i = 0; i < 128; i++) { printf("%4d, ",asc_ptr[i]); if ((i+1) % 8 == 0) printf("\n"); } printf("};\nchar data_table[NBYTES] = {\n"); printf(" /* "); for (i = 0; i < 10; i++) printf(" %3d ",i); printf(" */\n"); for (i = 0; i < NBYTES; i += 10) { printf("/* %4d */ ",i); for (j = i; j < i+10; j++) { x = data_table[j] & 0377; printf(" %3d, ",x); } putchar('\n'); } printf("};\n"); } /* check message to make sure it's legal */ j = 0; for (i = 0; i < nchars; i++) if ((u_char) message[i] >= NCHARS || asc_ptr[(u_char) message[i]] == 0) { warnx("The character '%c' is not in my character set", message[i]); j++; } if (j) exit(1); if (trace) printf("Message '%s' is OK\n",message); /* Now have message. Print it one character at a time. */ for (i = 0; i < nchars; i++) { if (trace) printf("Char #%d: %c\n", i, message[i]); for (j = 0; j < DWIDTH; j++) line[j] = ' '; pc = asc_ptr[(u_char) message[i]]; term = 0; max = 0; linen = 0; while (!term) { if (pc < 0 || pc > NBYTES) { printf("bad pc: %d\n",pc); exit(1); } x = data_table[pc] & 0377; if (trace) printf("pc=%d, term=%d, max=%d, linen=%d, x=%d\n",pc,term,max,linen,x); if (x >= 128) { if (x>192) term++; x = x & 63; while (x--) { if (print[linen++]) { for (j=0; j <= max; j++) if (print[j]) putchar(line[j]); putchar('\n'); } } for (j = 0; j < DWIDTH; j++) line[j] = ' '; pc++; } else { y = data_table[pc+1]; /* compensate for narrow teminals */ #ifdef notdef x = (x*width + (DWIDTH/2)) / DWIDTH; y = (y*width + (DWIDTH/2)) / DWIDTH; #endif max = x+y; while (x < max) line[x++] = '#'; pc += 2; if (trace) printf("x=%d, y=%d, max=%d\n",x,y,max); } } } exit(0); } bsd-games-2.17/banner/banner.60000664000175000017500000000507307767741711014626 0ustar jsm28jsm28.\" $NetBSD: banner.6,v 1.13 2003/08/07 09:36:59 agc Exp $ .\" .\" Copyright (c) 1980, 1993, 1995 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)banner.6 8.2 (Berkeley) 4/29/95 .\" .Dd April 29, 1995 .Dt BANNER 6 .Os .Sh NAME .Nm banner .Nd print large banner on printer .Sh SYNOPSIS .Nm .Op Fl w Ar width .Ar message ... .Sh DESCRIPTION .Nm prints a large, high quality banner on the standard output. If the message is omitted, it prompts for and reads one line of its standard input. If .Fl w is given, the output is scrunched down from a width of 132 to .Ar width , suitable for a narrow terminal. .Pp The output should be printed on paper of the appropriate width, with no breaks between the pages. .Sh BUGS Several ASCII characters are not defined, notably \*[Lt], \*[Gt], [, ], \\, ^, _, {, }, |, and ~. Also, the characters ", ', and \*[Am] are funny looking (but in a useful way.) .Pp The .Fl w option is implemented by skipping some rows and columns. The smaller it gets, the grainier the output. Sometimes it runs letters together. .Sh AUTHOR .An Mark Horton bsd-games-2.17/banner/Makefrag0000664000175000017500000000330406773402557014723 0ustar jsm28jsm28# Makefrag - makefile fragment for banner # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. banner_DIRS := $(GAMESDIR) $(MAN6DIR) banner_all: banner/banner banner/banner.6 banner_install: banner_all $(INSTALL_BINARY) banner/banner $(INSTALL_PREFIX)$(GAMESDIR)/banner $(HIDE_GAME) banner $(INSTALL_MANUAL) banner/banner.6 bsd-games-2.17/BUGS0000664000175000017500000000304107503721574012472 0ustar jsm28jsm28Known bugs in bsd-games and bsd-games-non-free ============================================== I know of the following bugs in bsd-games and bsd-games-non-free; there is no need to report them if you come across them, but fixes are welcome. General ======= Some games may not handle signals (especially resizing) properly. Handling signals properly means in a way conforming to ISO C and POSIX.1: no async-unsafe functions may be used in a signal handler if the signal could have interrupted an async-unsafe function, and any variable of static storage duration assigned to must be of type volatile sig_atomic_t. (See adventure for an example of proper handling.) Some games may not check for errors when they should, or may return inappropriate exit statuses. Some games may have arbitrary limits that they should not have. Specific games ============== Under some circumstances, hunt fails to start the hunt daemon if one is not already running. In general, hunt needs thorough testing by someone willing to investigate and fix bugs; at present hunt should be considered unsupported and probably broken. OpenBSD has a substantially improved version that should be imported/merged. Saving in monop is completely broken. Since it assumes it can save by writing out the whole data space from 0 to sbrk(0) and read it in to restore, it may not be easy to fix. See NetBSD PR bin/8247. Gomoku can use 16 megabytes or more of memory. (This is reported (not by me) as NetBSD PR 3126.) Joseph S. Myers jsm@polyomino.org.uk Local Variables: mode: text End: bsd-games-2.17/include/0000775000175000017500000000000010205246606013423 5ustar jsm28jsm28bsd-games-2.17/include/sys/0000775000175000017500000000000010205246606014241 5ustar jsm28jsm28bsd-games-2.17/include/sys/endian.h0000664000175000017500000000737106767673067015707 0ustar jsm28jsm28/* sys/endian.h - bsd-games compatibility with NetBSD (not * a complete emulation). * * Copyright (c) 1999 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #if __BYTE_ORDER == __BIG_ENDIAN #ifndef be16toh #define be16toh(x) ((u_int16_t)(x)) #endif #ifndef htobe16 #define htobe16(x) ((u_int16_t)(x)) #endif #ifndef be32toh #define be32toh(x) ((u_int32_t)(x)) #endif #ifndef htobe32 #define htobe32(x) ((u_int32_t)(x)) #endif #ifndef be64toh #define be64toh(x) ((u_int64_t)(x)) #endif #ifndef htobe64 #define htobe64(x) ((u_int64_t)(x)) #endif #ifndef BE16TOH #define BE16TOH(x) ((void)0) #endif #ifndef HTOBE16 #define HTOBE16(x) ((void)0) #endif #ifndef BE32TOH #define BE32TOH(x) ((void)0) #endif #ifndef HTOBE32 #define HTOBE32(x) ((void)0) #endif #ifndef BE64TOH #define BE64TOH(x) ((void)0) #endif #ifndef HTOBE64 #define HTOBE64(x) ((void)0) #endif #else /* little-endian */ #ifndef be16toh #define be16toh(x) ((u_int16_t)ntohs((u_int16_t)(x))) #endif #ifndef htobe16 #define htobe16(x) ((u_int16_t)htons((u_int16_t)(x))) #endif #ifndef be32toh #define be32toh(x) ((u_int32_t)ntohl((u_int32_t)(x))) #endif #ifndef htobe32 #define htobe32(x) ((u_int32_t)htonl((u_int32_t)(x))) #endif #ifndef be64toh #ifdef __bswap_64 /* glibc */ #define be64toh(x) ((u_int64_t)__bswap_64((u_int64_t)(x))) #else /* no __bswap_64 */ #ifdef __swab64 /* Linux kernel headers (libc5, at least with kernel 2.2) */ #define be64toh(x) ((u_int64_t)__swab64((u_int64_t)(x))) #else /* no __bswap_64 or __swab64 */ static __inline__ u_int64_t be64toh(u_int64_t __x); static __inline__ u_int64_t be64toh(u_int64_t __x) { return (((u_int64_t)be32toh(__x & (u_int64_t)0xFFFFFFFFULL)) << 32) | ((u_int64_t)be32toh((__x & (u_int64_t)0xFFFFFFFF00000000ULL) >> 32)); } #define be64toh(x) be64toh((x)) #endif /* no __bswap_64 or __swab64 */ #endif /* no __bswap_64 */ #endif /* no be64toh */ #ifndef htobe64 #define htobe64(x) be64toh(x) #endif #ifndef BE16TOH #define BE16TOH(x) ((x) = be16toh((x))) #endif #ifndef HTOBE16 #define HTOBE16(x) ((x) = htobe16((x))) #endif #ifndef BE32TOH #define BE32TOH(x) ((x) = be32toh((x))) #endif #ifndef HTOBE32 #define HTOBE32(x) ((x) = htobe32((x))) #endif #ifndef BE64TOH #define BE64TOH(x) ((x) = be64toh((x))) #endif #ifndef HTOBE64 #define HTOBE64(x) ((x) = htobe64((x))) #endif #endif /* little-endian */ bsd-games-2.17/include/sys/cdefs.h0000664000175000017500000000354407142406507015510 0ustar jsm28jsm28/* cdefs.h - bsd-games wrapper for . * * Copyright (c) 1997, 1998, 1999, 2000 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #pragma GCC system_header #endif #include_next #ifndef __RCSID #define __RCSID(arg) static const char rcsid[] __attribute__((__unused__)) = arg #endif #ifndef __COPYRIGHT #define __COPYRIGHT(arg) static const char copyright[] __attribute__((__unused__)) = arg #endif bsd-games-2.17/include/sys/poll.h0000664000175000017500000000323207641024615015364 0ustar jsm28jsm28/* poll.h - bsd-games wrapper for . * * Copyright (c) 2003 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #pragma GCC system_header #endif #include_next #ifndef INFTIM #define INFTIM -1 #endif bsd-games-2.17/include/sys/ttydefaults.h0000664000175000017500000000343607142406507016774 0ustar jsm28jsm28/* ttydefaults.h - bsd-games wrapper for . * * Copyright (c) 1997, 1998, 2000 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #pragma GCC system_header #endif #include #ifdef __GLIBC__ #include_next #endif #ifndef CTRL #define CTRL(x) ((x) & 037) #endif #ifndef OXTABS #define OXTABS XTABS #endif bsd-games-2.17/include/termios.h0000664000175000017500000000322607142406507015265 0ustar jsm28jsm28/* termios.h - bsd-games wrapper for . * * Copyright (c) 1998, 2000 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #pragma GCC system_header #endif #include_next #include bsd-games-2.17/include/signal.h0000664000175000017500000000360310005017256015046 0ustar jsm28jsm28/* signal.h - bsd-games wrapper for . * * Copyright (c) 1997, 1998, 2000, 2004 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #pragma GCC system_header #endif #include #ifndef __GLIBC__ #define __USE_BSD_SIGNAL 1 /* Get BSD signal semantics with libc5 */ #endif #include_next #ifndef HAVE_sig_t #ifndef LINUX_BSD_GAMES_DEFINED_SIG_T typedef void (*sig_t)(int); #define LINUX_BSD_GAMES_DEFINED_SIG_T 1 #endif #endif bsd-games-2.17/include/stdlib.h0000664000175000017500000000346310005553140015053 0ustar jsm28jsm28/* stdlib.h - bsd-games wrapper for . * * Copyright (c) 1998, 1999, 2000, 2004 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #pragma GCC system_header #endif #include #include_next #ifndef HAVE_getloadavg extern int getloadavg(double loadavg[], int nelem); #endif #ifndef HAVE_getprogname extern const char *getprogname(void); #endif bsd-games-2.17/include/stdio.h0000664000175000017500000000333307142406507014724 0ustar jsm28jsm28/* stdio.h - bsd-games wrapper for . * * Copyright (c) 1998, 1999, 2000 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #pragma GCC system_header #endif #include #include_next #ifndef HAVE_fgetln extern char *fgetln(FILE *stream, size_t *len); #endif bsd-games-2.17/include/string.h0000664000175000017500000000334207641024615015110 0ustar jsm28jsm28/* string.h - bsd-games wrapper for . * * Copyright (c) 2003 Joseph Samuel Myers. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) #pragma GCC system_header #endif #include #include_next #ifndef HAVE_strlcpy extern size_t strlcpy(char *dst, const char *src, size_t siz); #endif bsd-games-2.17/exec.libs0000664000175000017500000000436007775331303013611 0ustar jsm28jsm28# exec.libs - details of libraries needed to link bsd-games programs. # This file is used for automatic makefile generation. # # Copyright (c) 1998, 1999, 2000, 2003, 2004 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # atc -lm $(NCURSES_LIB) $(LEX_LIB) backgammon/backgammon/backgammon $(NCURSES_LIB) backgammon/teachgammon/teachgammon $(NCURSES_LIB) battlestar $(NCURSES_LIB) boggle/boggle/boggle $(NCURSES_LIB) caesar -lm canfield/canfield/canfield $(NCURSES_LIB) cribbage $(NCURSES_LIB) dab $(NCURSES_LIB) factor $(OPENSSL_LIB) gomoku $(NCURSES_LIB) hack $(NCURSES_LIB) hangman $(NCURSES_LIB) hunt/hunt/hunt $(NCURSES_LIB) mille $(NCURSES_LIB) phantasia -lm $(NCURSES_LIB) phantasia/setup -lm pom -lm primes -lm rain $(NCURSES_LIB) robots $(NCURSES_LIB) rogue $(NCURSES_LIB) sail $(NCURSES_LIB) snake/snake/snake $(NCURSES_LIB) -lm tetris $(NCURSES_LIB) trek -lm worm $(NCURSES_LIB) worms $(NCURSES_LIB) bsd-games-2.17/COPYING0000664000175000017500000006107110177154555013051 0ustar jsm28jsm28I believe that the following copyrights and licence terms apply to the games distributed in bsd-games and bsd-games-non-free. (The copyright years given below are those that appear on any of the files so licensed.) Most games are under the standard BSD terms: Copyright (c) 1980, 1982, 1983, 1985-1994 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The files "caesar/rot13.in" and "wargames/wargames" have a similar licence but with an additional advertising clause: Copyright (c) 1985, 1992, 1993 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors. 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The game "hunt" has a similar licence, mentioning the University of California, San Francisco: Copyright (c) 1983-2003, Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + Neither the name of the University of California, San Francisco nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. These terms also apply to "hunt/Makeconfig", which is derived from the hunt "Makefile.inc" distributed by NetBSD. The files "backgammon/backgammon/backlocal.h", "countmail/countmail", "dm/utmpentry.c", "dm/utmpentry.h", "hack/extern.h", "robots/auto.c", "sail/display.h", "sail/restart.h" and the game "dab" have a similar licence, but copyright is held by the NetBSD Foundation: Copyright (c) 1997, 1998, 1999, 2001, 2002, 2003 The NetBSD Foundation, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the NetBSD Foundation, Inc. and its contributors. 4. Neither the name of The NetBSD Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. In the case of "dab/dab.6", the copyright is held by Thomas Klausner: Copyright (c) 2003 Thomas Klausner. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. In the case of "adventure/extern.h" the copyright is held by Christos Zoulas: Copyright (c) 1997 Christos Zoulas. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by Christos Zoulas. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. In the case of "countmail/countmail.6" the copyright is held by Matthew R. Green: Copyright (c) 1997 Matthew R. Green All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. In the case of "wargames/wargames.6", the copyright is held by Joey Hess: Copyright (c) 1998 Joey Hess All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. In the case of "lib/strlcpy.c", the copyright is held by Todd C. Miller: Copyright (c) 1998 Todd C. Miller All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The game "atc" bears additional notices in the name of Ed James: Copyright (c) 1987 by Ed James, UC Berkeley. All rights reserved. Copy permission is hereby granted provided that this notice is retained on all partial or complete copies. For more info on this and all of my stuff, mail edjames@berkeley.edu. The game "boggle" used to bear a copyright notice in the name of Barry Brachman, but he confirmed that he had assigned his copyright to the University of California and the continued inclusion of the old copyright notice was an omission on their part. The game "phantasia" is not copyright (except for "phantasia/pathnames.h.in" to which the BSD copyright and licence apply); the notice in "phantasia/COPYRIGHT" applies to it. The game "wtf" is also not copyright, and bears the notice Public domain The game "rogue" (in bsd-games-non-free) bears the standard BSD notices, and then the following: This source herein may be modified and/or distributed by anybody who so desires, with the following restrictions: 1.) No portion of this notice shall be removed. 2.) Credit shall not be taken for the creation of this source. 3.) This code is not to be traded, sold, or used for personal gain or profit. The game "hack" has the following notices: Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, Amsterdam All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Stichting Centrum voor Wiskunde en Informatica, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (c) 1982 Jay Fenlason All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "hack/pathnames.h" bears a BSD copyright notice and licence; "hack/hack.tty.c" bears one in addition to that in those listed above; "hack/extern.h" bears the notice in the name of The NetBSD Foundation listed above. Auxiliary and data files, distributed with the games in NetBSD, but not bearing copyright notices, probably fall under the terms of the UCB or NetBSD copyrights and licences. The file "fortune/Notes" contains a warning in regard to the fortune databases. Some files, beyond those present in NetBSD, have been added to the Linux bsd-games collection. The following terms apply to the files in the "include" and "lib" directories (relevant to binary distributions insofar as they get compiled into the games; note that the include files are probably irrelevant for this purpose as it is unlikely they are significant enough to make any binary a derived work). Copyright (c) 1997-2005 Joseph Samuel Myers. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The above terms also apply to the scripts, makefile fragments and documentation added to the Linux bsd-games collection which are not significantly derived from bsd-games 1.3 by Curt Olson and Andy Tefft; this is all of them except for the files mentioned below to which the similar terms given below are expected to apply. This includes the testsuite scripts; the testsuite input and output for caesar ("tests/caesar.constin" and "tests/caesar.constout") are from the US Constitution, so not copyright; I believe the other testsuite expected outputs are too trivial, or translations of inputs too trivial, to qualify for copyright; but if not, then the terms given above apply (and, of course, running the test command gives an identical output file to which you could apply your own copyright). The files "bsd-games.lsm", "ChangeLog.0", "THANKS", "INSTALL" and "README" are still significantly derived from files in the original bsd-games package for Linux by Curt Olson and Andy Tefft. It is expected that the following terms will apply to these files, and to the compilation copyright on the package as a whole; ***this has yet to be confirmed with Andy Tefft***: Copyright (c) 1993 Curt Olson, Andy Tefft. Copyright (c) 1997-2005 Joseph Samuel Myers. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Local Variables: mode: text End: bsd-games-2.17/substfiles0000664000175000017500000000374107077410364014122 0ustar jsm28jsm28# substfiles - list of files in which parameters are to be substituted. # These ones get substituted in at configure time. # # Copyright (c) 1997, 1998, 1999, 2000 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # Makeconfig hide-game install-man install-score atc/pathnames.h battlestar/pathnames.h boggle/boggle/bog.h canfield/canfield/pathnames.h cribbage/pathnames.h dm/pathnames.h fish/pathnames.h fortune/fortune/pathnames.h hack/pathnames.h hangman/pathnames.h monop/pathnames.h phantasia/pathnames.h quiz/pathnames.h robots/pathnames.h rogue/pathnames.h sail/pathnames.h snake/snake/pathnames.h tetris/pathnames.h wump/pathnames.h bsd-games-2.17/NEWS0000664000175000017500000003411610205245257012505 0ustar jsm28jsm28NEWS for bsd-games and bsd-games-non-free ========================================= This file contains a summary of changes in each version of bsd-games and bsd-games-non-free after 1.3. For fuller details, see ChangeLog and ChangeLog.0. As well as reading this summary, it is a good idea to reread the INSTALL file whenever installing a new version, to check for any changes in installation instructions. Packagers should also reread the PACKAGING file each version (or do a diff between the old and new versions of the package and read that). Version 2.17 (2005-02-18) ============ * Updated from NetBSD CVS of 2005-02-18. * Some bugs fixed (in particular, should now build with current GCC 4 CVS), some backlogged. Version 2.16 (2004-02-13) ============ * Updated from NetBSD CVS of 2004-02-13. Includes a new game, dab (Dots and Boxes), written in C++. * Supplementary documentation for trek and rogue now installed automatically (in a configurable directory). * Some changes for portability to Cygwin, thanks to David A Bagley ; more portability issues remain. * Various improvements to morse from OpenBSD. * Some bugs fixed, some backlogged. Version 2.15 (2003-12-18) ============ * Updated from NetBSD CVS of 2003-12-17. This includes: + Advertising clause removed from licence of almost all UCB-copyright code. + Hunt licence clarified. * Various bugs fixed, though some bug reports are still backlogged. * Glibc 2.3 or later now required, at least for hunt. * Directory for fortune files individually configurable, and default has changed to match that used in NetBSD. Version 2.14 (2003-04-01) ============ * Hack is now BSD-licensed , so moves from bsd-games-non-free to bsd-games. * Updated from NetBSD CVS of 2003-03-29. This includes: + Security fix for rogue (in bsd-games-non-free); see NetBSD Security Advisory 2002-021. + Optional support for large numbers in factor using libcrypto from OpenSSL. This can handle larger numbers than GNU factor (which is limited to 64-bit numbers) but not that much larger efficiently, as the algorithm used (Pollard rho) is O(n^{1/4}) in the number factored. * Some bugs fixed, though a backlog of bug reports remains. Version 2.13 (2001-08-30) ============ * Warning now present in README about the inclusion of cryptographic software (caesar and rot13). * Various minor improvements and bugfixes, some from NetBSD, some from OpenBSD, some from other contributors. Current with NetBSD CVS of 2001-08-29. * Some fixes to avoid some warnings when compiling with current glibc and GCC 3. * May support GNU Hurd (untested). Version 2.12 (2000-09-25) ============ * Improvements and bugfixes to battlestar, mainly from OpenBSD. Though there are still plenty of known bugs, it should be much harder to crash. * Should compile with glibc 2.2 (tested with 2.1.94). * Other minor changes and bugfixes; current with NetBSD CVS of 2000-09-25. Version 2.11 (2000-04-19) ============ * bsd-games-non-free now includes hack 1.0.3 by Andries Brouwer; this may be of interest to nethack players wishing to play an ancestral game. * Various minor changes and bugfixes; current with NetBSD CVS of 2000-04-19. Version 2.10 (2000-02-12) ============ * Avoid world-readable characs file in phantasia. Note the new configuration question which will need an appropriate answer, especially if packaging for a distribution. * Various minor bugfixes. * Essentially all relevant changes, except to hunt (which will eventually be replaced by the OpenBSD version), now merged back into NetBSD. * Some minor changes from NetBSD CVS of 2000-02-12. * No new bsd-games-non-free version; bsd-games-non-free 2.8 is still current. Version 2.9 (1999-11-12) =========== * Fixes various minor bugs reported recently. * Some minor changes from NetBSD CVS of 1999-11-12. * No new bsd-games-non-free version; bsd-games-non-free 2.8 is still current. Version 2.8 (1999-09-26) =========== * Robots scorefile format has changed - remove or rename your old score file when upgrading to this version. * Various minor changes and bug-fixes (some from OpenBSD). * Snake substantially cleaned up, and now uses the native curses interface (rather than termcap emulation in ncurses); backgammon and tetris still to be converted. * New "game": wtf. * Updated from NetBSD CVS of 1999-09-25; many more changes merged back into NetBSD. * All constant data files are now architecture independent (installed under /usr/share by default). * bsd-games is no longer tested by me with libc older than glibc 2.1.2; fixes for compilation with older libc will still be accepted. * Details of the copyrights and licence terms applicable to these games, as best as I can determine them, now appear in COPYING. * bsd-games no longer comes with its own word list for boggle and hangman; you need to provide one at compile time (for boggle) and at run time (for hangman). The copyright status of the one formerly included was not entirely clear. The word list used by hangman can also now be specified at run time with the new "-d" option. * bsd-games now has a testsuite (for programs that can be tested non-interactively only). Version 2.7 (1999-04-04) =========== * Bug fixes. * Updated from NetBSD-current of 1999-03-26; more changes merged back into NetBSD. * Other minor changes. Version 2.6 (1998-12-20) =========== * Buffer overrun fixes in sail (not thought exploitable). * Fixes possible score file corruption if fds 0, 1, 2 aren't open at game startup. * Updated from NetBSD-current of 1998-12-07 (morse now has a decoding option). * Now builds cleanly with -Wwrite-strings. * Other minor changes. * Some users of this package may be interested in my "nppt" package, which provides an alternative implementation of ppt(6) with additional features such as Encapsulated PostScript output. (This package installs the binary as "nppt", so can be installed simultaneously with this one. Look for nppt-0.1.tar.gz (or a later version) on metalab.unc.edu (formerly sunsite) in /pub/Linux/Incoming/ or under /pub/Linux/games/.) Version 2.5 (1998-09-24) =========== * New build system, using a single project Makefile (autogenerated) that includes makefile fragments from subdirectories, and uses GNU Make's automatic dependency generation to generate dependencies automatically, rather than recursive make. See Peter Miller's paper "Recursive Make Considered Harmful" for reasons why this is better than recursive make. This should make no difference to normal users, but if you modify the sources note that you will need to rebuild from the top directory, and you may find that the dependencies are now accurate whereas formerly they were incomplete. The automatic dependency generation causes the build to start with about 300 "no such file or directory" warnings, which should be ignored: these refer to the dependency files which GNU Make will then automatically generate. * Should work with glibc 2.1 (at least, version 2.0.96 on x86, which is what I've tested). See the ChangeLog for an explanation of the problem previous releases had with glibc 2.1. * Boggle is now in the main bsd-games package - Paul Janzen checked with the original author, who confirmed that the BSD licence superseded the old non-free one. bsd-games-non-free now only contains rogue. * Other minor changes. Version 2.4 (1998-09-05) =========== * Various minor bug fixes and improvements (some from OpenBSD, thanks to Paul Janzen ). * Sail directory can now be non-world-accessible (mode 2770 root.games or similar). This may improve security, since it means users cannot tamper with sync files their sail process creates. * Rogue buffer overrun fix. An audit is still needed. * dm now ignores the environment variable TZ when deciding at what times games can be played. (This only affects you if you are using dm to control at what times games can be played, and not then if you are using libc 5.4.45 or 5.4.46 (which completely ignore TZ in setgid programs rather than checking the validity of any filename given as glibc does).) * All games updated from NetBSD-current of 1998-08-30 (minor changes; some more of my changes have been merged back into NetBSD). Version 2.3 (1998-08-19) =========== * A possible temporary file security bug in sail fixed. * Countmail is back, with a licence (apparently the standard NetBSD one), since it has one in NetBSD-current of 1998-08-19. * All the other games updated from NetBSD-current of 1998-08-19 (minor changes). * Other minor changes. * Version 2.2 was never properly released, since the upload to sunsite was truncated and the sail hole was found before the truncated file had been removed or the release put in place on tsx-11. Version 2.2 (1998-08-15) =========== * Another bug-fix release. * This version includes security fixes from OpenBSD. * This release is believed year 2000 compliant. Please see the year 2000 statement in the file YEAR2000 for details and disclaimer. * Paranoia has been removed from bsd-games-non-free, since it has no clear licence at all, and being derived from a magazine article it is not clear it was ever legally distributable. Anyone wanting to resurrect it in a separate package would need to investigate the copyright on the magazine article as well as getting a proper licence from the author. * Countmail has been removed from bsd-games because of the lack of a licence. * All other games updated from NetBSD-current of 1998-07-27 (very minor changes). * Default paths now follow FHS 2.0 - enter the paths you want when running configure if you are using the FSSTND 1.2. * You can now easily specify games you don't want built when running configure. * All games that can invoke pagers handle PAGER in the way specified by POSIX.2 for standard programs that invoke pagers. * Rogue bug fix from Bill Lash . * Other bug fixes. * Information for those packaging bsd-games or bsd-games-non-free for a Linux distribution is in the file PACKAGING. Version 2.1 (1998-03-29) =========== * This is mainly a bug-fix release. * All games updated to NetBSD-current as of 1998-03-21 (except for paranoia). The changes are mostly minor, replacing warning fixes local to bsd-games with ones now in NetBSD. * Some bugs fixed, and most of the additional warnings given by the current egcs snapshot fixed as well. * Configuration / installation change - to strip the installed binaries, use "make install-strip" instead of "make install"; this replaces the configuration option for "make install" to strip the installed binaries. * Manpages for wargames and paranoia, thanks to Joey Hess . * Battlestar save file name can be chosen at runtime, and defaults to ".Bstar" instead of "Bstar" for cleaner directory listings. Version 2.0 (1997-12-25) =========== * All games updated to NetBSD-current as of 1997-12-12 (except for paranoia). Hunt and boggle are now based on the NetBSD versions. * Many bugs fixed. * Added countmail. * Better libc6 support - adventure should now work. * No longer uses libbsd with libc5. * Nearly warning-free compile with -Wall -W -Wstrict-prototypes -Wmissing-prototypes. * Hunt now uses internet domain sockets (untested). Version 1.5 (1997-07-17) =========== * All games updated to NetBSD-current as of 1997-07-12 (except for bog, hunt and paranoia). * Added adventure, banner, dm, phantasia, pig, quiz, random and rogue. (Rogue is in bsd-games-non-free only). * BETA level libc6 support. (It may not yet compile, but should be nearer to compiling with libc6 than version 1.4.) Version 1.4 (1997-05-07) =========== * Fish, fortune and hangman updated to the versions in NetBSD-current. * Public release. Version 1.3.4beta (1997-05-06) ================= * Bug fix in backgammon. * Backgammon, battlestar, bcd, caesar, canfield, cribbage and factor updated to the versions in NetBSD-current. As a side-effect, caesar now installs a "rot13" script. * Tetris score file now defaults to tetris-bsd.scores for consistency with using tetris-bsd in the names of files installed from tetris. (The rationale of this is that there is more than one Tetris game and this one should not presume to be the one that takes the /usr/games/tetris name; that should be a decision for the administrator, who can reasonably install more than one Tetris game.) Nor should other files such as the man page or score file potentially conflict with other Tetris games. Of course, you can configure the package to use the old score file name (or any other) if you want. Version 1.3.3beta (1997-05-03) ================= * Non-free package now contains all the files required to build on its own. It can now be built on its own, or in the same source tree as bsd-games; the files that appear in both are exact duplicates. * Bug-fixes in backgammon and sail. Version 1.3.2beta (1997-05-03) ================= * Non-free games (bog and paranoia) now distributed separately - unpack both source packages together before configuring if you want to build them. * Configuration script improved: now the default list of games to build is the list of subdirectories, and you can configure the exact paths to score files and data files for individual games using it - so they are always correctly substituted in the manpages. * Bug-fixes in backgammon, snake and worm. * Arithmetic and atc updated to the versions in NetBSD-current. Version 1.3.1beta (1997-05-01) ================= * Now works with libc 5 ;-). * Debian patches from Joey Hess mostly integrated up to Debian version 1.3-7. * New ports of tetris and gomoku, thanks to David Frey . * Distributed as source only. * Many bug-fixes to battlestar. * Configuration script, now substitutes correct paths in manpages. * Defaults hopefully closer to FSSTND/FHS. * Builds with ncurses by default. Curses/termcap are obsolete and no longer supported (not that this package is supported anyway ;-)). Version 1.3 (1993-10-25) =========== See ChangeLog.0. Version 1.2 (1993-08-25) =========== See ChangeLog.0. Version 1.1 (1993-08-19) =========== See ChangeLog.0. Local Variables: mode: text End: bsd-games-2.17/morse/0000775000175000017500000000000010205246606013125 5ustar jsm28jsm28bsd-games-2.17/morse/Makefile.bsd0000664000175000017500000000025507641024615015342 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.6 2002/09/18 06:16:40 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 NOMAN= # defined PROG= morse HIDEGAME= hidegame .include bsd-games-2.17/morse/morse.c0000664000175000017500000001223610013255454014420 0ustar jsm28jsm28/* $NetBSD: morse.c,v 1.13 2004/02/13 23:16:11 jsm Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)morse.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: morse.c,v 1.13 2004/02/13 23:16:11 jsm Exp $"); #endif #endif /* not lint */ #include #include #include #include #include static const char *const digit[] = { "-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----.", }, *const alph[] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", }; const struct punc { char c; const char *morse; } other[] = { { '.', ".-.-.-" }, { ',', "--..--" }, { ':', "---..." }, { '?', "..--.." }, { '\'', ".----." }, { '-', "-....-" }, { '/', "-..-." }, { '(', "-.--." }, { ')', "-.--.-" }, { '"', ".-..-." }, { '=', "-...-" }, { '+', ".-.-." }, { '\0', NULL } }; int main(int, char *[]); void morse(int); void decode(const char *); void show(const char *); static int sflag; static int dflag; int main(argc, argv) int argc; char **argv; { int ch; char *p; /* Revoke setgid privileges */ setregid(getgid(), getgid()); while ((ch = getopt(argc, argv, "ds")) != -1) switch((char)ch) { case 'd': dflag = 1; break; case 's': sflag = 1; break; case '?': default: fprintf(stderr, "usage: morse [-ds] [string ...]\n"); exit(1); } argc -= optind; argv += optind; if (dflag) { if (*argv) { do { decode(*argv); } while (*++argv); } else { char foo[10]; /* All morse chars shorter than this */ int isblank, i; i = 0; isblank = 0; while ((ch = getchar()) != EOF) { if (ch == '-' || ch == '.') { foo[i++] = ch; if (i == 10) { /* overrun means gibberish--print 'x' and * advance */ i = 0; putchar('x'); while ((ch = getchar()) != EOF && (ch == '.' || ch == '-')) ; isblank = 1; } } else if (i) { foo[i] = '\0'; decode(foo); i = 0; isblank = 0; } else if (isspace(ch)) { if (isblank) { /* print whitespace for each double blank */ putchar(' '); isblank = 0; } else isblank = 1; } } } putchar('\n'); } else { if (*argv) do { for (p = *argv; *p; ++p) morse((int)*p); show(""); } while (*++argv); else while ((ch = getchar()) != EOF) morse(ch); show("...-.-"); /* SK */ } return 0; } void decode(s) const char *s; { int i; for (i = 0; i < 10; i++) if (strcmp(digit[i], s) == 0) { putchar('0' + i); return; } for (i = 0; i < 26; i++) if (strcmp(alph[i], s) == 0) { putchar('A' + i); return; } i = 0; while (other[i].c) { if (strcmp(other[i].morse, s) == 0) { putchar(other[i].c); return; } i++; } if (strcmp("...-.-", s) == 0) return; putchar('x'); /* line noise */ } void morse(c) int c; { int i; if (isalpha(c)) show(alph[c - (isupper(c) ? 'A' : 'a')]); else if (isdigit(c)) show(digit[c - '0']); else if (isspace(c)) show(""); /* could show BT for a pause */ else { i = 0; while (other[i].c) { if (other[i].c == c) { show(other[i].morse); break; } i++; } } } void show(s) const char *s; { if (sflag) printf(" %s", s); else for (; *s; ++s) printf(" %s", *s == '.' ? "dit" : "daw"); printf("\n"); } bsd-games-2.17/morse/Makefrag0000664000175000017500000000325506773402557014610 0ustar jsm28jsm28# Makefrag - makefile fragment for morse # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. morse_DIRS := $(GAMESDIR) $(MAN6DIR) morse_all: morse/morse morse_install: morse_all $(INSTALL_BINARY) morse/morse $(INSTALL_PREFIX)$(GAMESDIR)/morse $(HIDE_GAME) morse $(INSTALL_MANUAL) bcd.6 morse.6 bsd-games-2.17/sail/0000775000175000017500000000000010205246607012731 5ustar jsm28jsm28bsd-games-2.17/sail/pathnames.h.in0000664000175000017500000000345407767741711015514 0ustar jsm28jsm28/* $NetBSD: pathnames.h,v 1.5 2003/08/07 09:37:43 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 5/31/93 */ #define _PATH_LOGFILE "@sail_scorefile@" #define _PATH_SYNC "@sail_dir@/#sailsink.%d" #define _PATH_LOCK "@sail_dir@/#saillock.%d" bsd-games-2.17/sail/Makefile.bsd0000664000175000017500000000063307131162660015142 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.13 2000/06/11 15:37:51 mycroft Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= sail SRCS= main.c pl_main.c pl_1.c pl_2.c pl_3.c pl_4.c pl_5.c pl_6.c pl_7.c \ dr_main.c dr_1.c dr_2.c dr_3.c dr_4.c dr_5.c lo_main.c \ assorted.c game.c globals.c misc.c parties.c sync.c version.c MAN= sail.6 DPADD= ${LIBCURSES} LDADD= -lcurses HIDEGAME=hidegame SETGIDGAME=yes .include bsd-games-2.17/sail/parties.c0000664000175000017500000000505407767741711014567 0ustar jsm28jsm28/* $NetBSD: parties.c,v 1.11 2003/08/07 09:37:43 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)parties.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: parties.c,v 1.11 2003/08/07 09:37:43 agc Exp $"); #endif #endif /* not lint */ #include #include "extern.h" int meleeing(struct ship *from, struct ship *to) { struct BP *p = from->file->OBP; struct BP *q = p + NBP; for (; p < q; p++) if (p->turnsent && p->toship == to) return 1; return 0; } int boarding(struct ship *from, int isdefense) { struct BP *p = isdefense ? from->file->DBP : from->file->OBP; struct BP *q = p + NBP; for (; p < q; p++) if (p->turnsent) return 1; return 0; } void unboard(struct ship *ship, struct ship *to, int isdefense) { struct BP *p = isdefense ? ship->file->DBP : ship->file->OBP; int n; for (n = 0; n < NBP; p++, n++) if (p->turnsent && (p->toship == to || isdefense || ship == to)) Write(isdefense ? W_DBP : W_OBP, ship, n, 0, 0, 0); } bsd-games-2.17/sail/display.h0000664000175000017500000000442107240362720014550 0ustar jsm28jsm28/* $NetBSD: display.h,v 1.2 2001/01/04 05:06:15 jwise Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef SIGTSTP #define SCREENTEST() (initscr() != NULL && signal(SIGTSTP, SIG_DFL) != SIG_ERR && STAT_R < COLS && SCROLL_Y > 0) #else #define SCREENTEST() (initscr() != NULL && STAT_R < COLS && SCROLL_Y > 0) #endif extern WINDOW *view_w; extern WINDOW *slot_w; extern WINDOW *scroll_w; extern WINDOW *stat_w; extern WINDOW *turn_w; bsd-games-2.17/sail/extern.h0000664000175000017500000002452010011302370014373 0ustar jsm28jsm28/* $NetBSD: extern.h,v 1.27 2004/02/08 00:32:48 jsm Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)externs.h 8.1 (Berkeley) 5/31/93 */ #include #include "machdep.h" /* program mode */ extern int mode; #define MODE_PLAYER 1 #define MODE_DRIVER 2 #define MODE_LOGGER 3 /* command line flags */ extern int randomize; /* -x, give first available ship */ extern int longfmt; /* -l, print score in long format */ extern int nobells; /* -b, don't ring bell before Signal */ /* other initial modes */ extern gid_t gid; extern gid_t egid; #define dieroll() ((random()) % 6 + 1) #define sqr(a) ((a) * (a)) #define min(a,b) ((a) < (b) ? (a) : (b)) #define grappled(a) ((a)->file->ngrap) #define fouled(a) ((a)->file->nfoul) #define snagged(a) (grappled(a) + fouled(a)) #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count) #define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count) #define snagged2(a, b) (grappled2(a, b) + fouled2(a, b)) #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0) #define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0) #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b)) #define cleangrapple(a, b, c) Cleansnag(a, b, c, 1) #define cleanfoul(a, b, c) Cleansnag(a, b, c, 2) #define cleansnag(a, b, c) Cleansnag(a, b, c, 3) #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0)) #define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir]) #define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir]) #define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp)) #define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' ')) /* loadL and loadR, should match loadname[] */ #define L_EMPTY 0 /* should be 0, don't change */ #define L_GRAPE 1 #define L_CHAIN 2 #define L_ROUND 3 #define L_DOUBLE 4 #define L_EXPLODE 5 /* * readyL and readyR, these are bits, except R_EMPTY */ #define R_EMPTY 0 /* not loaded and not loading */ #define R_LOADING 1 /* loading */ #define R_DOUBLE 2 /* loading double */ #define R_LOADED 4 /* loaded */ #define R_INITIAL 8 /* loaded initial */ #define HULL 0 #define RIGGING 1 #define W_CAPTAIN 1 #define W_CAPTURED 2 #define W_CLASS 3 #define W_CREW 4 #define W_DBP 5 #define W_DRIFT 6 #define W_EXPLODE 7 #define W_FILE 8 #define W_FOUL 9 #define W_GUNL 10 #define W_GUNR 11 #define W_HULL 12 #define W_MOVE 13 #define W_OBP 14 #define W_PCREW 15 #define W_UNFOUL 16 #define W_POINTS 17 #define W_QUAL 18 #define W_UNGRAP 19 #define W_RIGG 20 #define W_COL 21 #define W_DIR 22 #define W_ROW 23 #define W_SIGNAL 24 #define W_SINK 25 #define W_STRUCK 26 #define W_TA 27 #define W_ALIVE 28 #define W_TURN 29 #define W_WIND 30 #define W_FS 31 #define W_GRAP 32 #define W_RIG1 33 #define W_RIG2 34 #define W_RIG3 35 #define W_RIG4 36 #define W_BEGIN 37 #define W_END 38 #define W_DDEAD 39 #define NLOG 10 struct logs { char l_name[20]; int l_uid; int l_shipnum; int l_gamenum; int l_netpoints; }; struct BP { short turnsent; struct ship *toship; short mensent; }; struct snag { short sn_count; short sn_turn; }; #define NSCENE nscene #define NSHIP 10 #define NBP 3 #define NNATION 8 #define N_A 0 #define N_B 1 #define N_S 2 #define N_F 3 #define N_J 4 #define N_D 5 #define N_K 6 #define N_O 7 struct File { int index; char captain[20]; /* 0 */ short points; /* 20 */ unsigned char loadL; /* 22 */ unsigned char loadR; /* 24 */ unsigned char readyL; /* 26 */ unsigned char readyR; /* 28 */ struct BP OBP[NBP]; /* 30 */ struct BP DBP[NBP]; /* 48 */ char struck; /* 66 */ struct ship *captured; /* 68 */ short pcrew; /* 70 */ char movebuf[10]; /* 72 */ char drift; /* 82 */ short nfoul; short ngrap; struct snag foul[NSHIP]; /* 84 */ struct snag grap[NSHIP]; /* 124 */ char RH; /* 224 */ char RG; /* 226 */ char RR; /* 228 */ char FS; /* 230 */ char explode; /* 232 */ char sink; /* 234 */ unsigned char dir; short col; short row; char loadwith; char stern; }; struct ship { const char *shipname; /* 0 */ struct shipspecs *specs; /* 2 */ unsigned char nationality; /* 4 */ short shiprow; /* 6 */ short shipcol; /* 8 */ char shipdir; /* 10 */ struct File *file; /* 12 */ }; struct scenario { char winddir; /* 0 */ char windspeed; /* 2 */ char windchange; /* 4 */ unsigned char vessels; /* 12 */ const char *name; /* 14 */ struct ship ship[NSHIP]; /* 16 */ }; extern struct scenario scene[]; extern int nscene; struct shipspecs { char bs; char fs; char ta; short guns; unsigned char class; char hull; unsigned char qual; char crew1; char crew2; char crew3; char gunL; char gunR; char carL; char carR; int rig1; int rig2; int rig3; int rig4; short pts; }; extern struct shipspecs specs[]; extern struct scenario *cc; /* the current scenario */ extern struct ship *ls; /* &cc->ship[cc->vessels] */ #define SHIP(s) (&cc->ship[s]) #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++) struct windeffects { char A, B, C, D; }; extern const struct windeffects WET[7][6]; struct Tables { char H, G, C, R; }; extern const struct Tables RigTable[11][6]; extern const struct Tables HullTable[11][6]; extern const char AMMO[9][4]; extern const char HDT[9][10]; extern const char HDTrake[9][10]; extern const char QUAL[9][5]; extern const char MT[9][3]; extern const char *const countryname[]; extern const char *const classname[]; extern const char *const directionname[]; extern const char *const qualname[]; extern const char loadname[]; extern const char rangeofshot[]; extern const char dr[], dc[]; extern int winddir; extern int windspeed; extern int turn; extern int game; extern int alive; extern int people; extern int hasdriver; /* assorted.c */ void table (struct ship *, struct ship *, int, int, int, int); void Cleansnag (struct ship *, struct ship *, int, int); /* dr_1.c */ void unfoul (void); void boardcomp (void); void resolve (void); void compcombat (void); int next (void); /* dr_2.c */ void thinkofgrapples (void); void checkup (void); void prizecheck (void); void closeon (struct ship *, struct ship *, char *, int, int, int); /* dr_3.c */ void moveall (void); void sendbp (struct ship *, struct ship *, int, int); int is_toughmelee (struct ship *, struct ship *, int, int); void reload (void); void checksails (void); /* dr_4.c */ void ungrap (struct ship *, struct ship *); void grap (struct ship *, struct ship *); /* dr_5.c */ void subtract (struct ship *, struct ship *, int, int [3], int); int mensent (struct ship *, struct ship *, int[3], struct ship **, int *, int); /* dr_main.c */ int dr_main (void); /* game.c */ int maxturns (struct ship *, char *); int maxmove (struct ship *, int, int); /* lo_main.c */ int lo_main (void); /* misc.c */ int range (struct ship *, struct ship *); struct ship *closestenemy (struct ship *, int, int); int gunsbear (struct ship *, struct ship *); int portside (struct ship *, struct ship *, int); int colours (struct ship *); void logger (struct ship *); /* parties.c */ int meleeing (struct ship *, struct ship *); int boarding (struct ship *, int); void unboard (struct ship *, struct ship *, int); /* pl_1.c */ void leave (int) __attribute__((__noreturn__)); void choke (int) __attribute__((__noreturn__)); void child (int); /* pl_2.c */ void play (void) __attribute__((__noreturn__)); /* pl_3.c */ void acceptcombat (void); void grapungrap (void); void unfoulplayer (void); /* pl_4.c */ void changesail (void); void acceptsignal (void); void lookout (void); const char *saywhat (struct ship *, int); void eyeball (struct ship *); /* pl_5.c */ void acceptmove (void); void acceptboard (void); /* pl_6.c */ void repair (void); void loadplayer (void); /* pl_7.c */ void initscreen (void); void cleanupscreen (void); void newturn (int); void Signal (const char *, struct ship *, ...) __attribute__((__format__(__printf__,1,3))); void Msg (const char *, ...) __attribute__((__format__(__printf__,1,2))); void prompt (const char *, struct ship *); int sgetch (const char *, struct ship *, int); void sgetstr (const char *, char *, int); void draw_screen (void); void draw_view (void); void draw_turn (void); void draw_stat (void); void draw_slot (void); void draw_board (void); void centerview (void); void upview (void); void downview (void); void leftview (void); void rightview (void); /* pl_main.c */ int pl_main (void); /* sync.c */ void fmtship (char *, size_t, const char *, struct ship *); void makesignal (struct ship *, const char *, struct ship *, ...) __attribute__((__format__(__printf__,2,4))); void makemsg (struct ship *, const char *, ...) __attribute__((__format__(__printf__,2,3))); int sync_exists (int); int sync_open (void); void sync_close (int); void Write (int, struct ship *, long, long, long, long); void Writestr (int, struct ship *, const char *); int Sync (void); bsd-games-2.17/sail/sail.60000664000175000017500000010545207767741711013776 0ustar jsm28jsm28.\" $NetBSD: sail.6,v 1.13 2003/08/07 09:37:44 agc Exp $ .\" .\" Copyright (c) 1988, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sail.6 8.3 (Berkeley) 6/1/94 .\" .TH SAIL 6 "June 1, 1994" .UC 4 .SH NAME sail \- multi-user wooden ships and iron men .SH SYNOPSIS .B sail [ .B \-s [ .B \-l ] ] [ .B \-x ] [ .B \-b ] [ .B num ] .br .fi .SH DESCRIPTION .I Sail is a computer version of Avalon Hill's game of fighting sail originally developed by S. Craig Taylor. .PP Players of .I Sail take command of an old fashioned Man of War and fight other players or the computer. They may re-enact one of the many historical sea battles recorded in the game, or they can choose a fictional battle. .PP As a sea captain in the .I Sail Navy, the player has complete control over the workings of his ship. He must order every maneuver, change the set of his sails, and judge the right moment to let loose the terrible destruction of his broadsides. In addition to fighting the enemy, he must harness the powers of the wind and sea to make them work for him. The outcome of many battles during the age of sail was decided by the ability of one captain to hold the `weather gage.' .PP The flags are: .TP .B \-s Print the names and ships of the top ten sailors. .TP .B \-l Show the login name. Only effective with \fB-s\fP. .TP .B \-x Play the first available ship instead of prompting for a choice. .TP .B \-b No bells. .SH IMPLEMENTATION .I Sail is really two programs in one. Each player starts up a process which runs his own ship. In addition, a .I driver process is forked (by the first player) to run the computer ships and take care of global bookkeeping. .PP Because the .I driver must calculate moves for each ship it controls, the more ships the computer is playing, the slower the game will appear. .PP If a player joins a game in progress, he will synchronize with the other players (a rather slow process for everyone), and then he may play along with the rest. .PP To implement a multi-user game in Version 7 UNIX, which was the operating system .I Sail was first written under, the communicating processes must use a common temporary file as a place to read and write messages. In addition, a locking mechanism must be provided to ensure exclusive access to the shared file. For example, .I Sail uses a temporary file named /tmp/#sailsink.21 for scenario 21, and corresponding file names for the other scenarios. To provide exclusive access to the temporary file, .I Sail uses a technique stolen from an old game called "pubcaves" by Jeff Cohen. Processes do a busy wait in the loop .br .sp .ce 2 for (n = 0; link(sync_file, sync_lock) \*[Lt] 0 \*[Am]\*[Am] n \*[Lt] 30; n++) sleep(2); .br .sp until they are able to create a link to a file named "/tmp/#saillock.??". The "??" correspond to the scenario number of the game. Since UNIX guarantees that a link will point to only one file, the process that succeeds in linking will have exclusive access to the temporary file. .PP Whether or not this really works is open to speculation. When ucbmiro was rebooted after a crash, the file system check program found 3 links between the .I Sail temporary file and its link file. .SH CONSEQUENCES OF SEPARATE PLAYER AND DRIVER PROCESSES When players do something of global interest, such as moving or firing, the driver must coordinate the action with the other ships in the game. For example, if a player wants to move in a certain direction, he writes a message into the temporary file requesting the driver to move his ship. Each ``turn,'' the driver reads all the messages sent from the players and decides what happened. It then writes back into the temporary file new values of variables, etc. .PP The most noticeable effect this communication has on the game is the delay in moving. Suppose a player types a move for his ship and hits return. What happens then? The player process saves up messages to be written to the temporary file in a buffer. Every 7 seconds or so, the player process gets exclusive access to the temporary file and writes out its buffer to the file. The driver, running asynchronously, must read in the movement command, process it, and write out the results. This takes two exclusive accesses to the temporary file. Finally, when the player process gets around to doing another 7 second update, the results of the move are displayed on the screen. Hence, every movement requires four exclusive accesses to the temporary file (anywhere from 7 to 21 seconds depending upon asynchrony) before the player sees the results of his moves. .PP In practice, the delays are not as annoying as they would appear. There is room for "pipelining" in the movement. After the player writes out a first movement message, a second movement command can then be issued. The first message will be in the temporary file waiting for the driver, and the second will be in the file buffer waiting to be written to the file. Thus, by always typing moves a turn ahead of the time, the player can sail around quite quickly. .PP If the player types several movement commands between two 7 second updates, only the last movement command typed will be seen by the driver. Movement commands within the same update "overwrite" each other, in a sense. .SH THE HISTORY OF SAIL I wrote the first version of .I Sail on a PDP\-11/70 in the fall of 1980. Needless to say, the code was horrendous, not portable in any sense of the word, and didn't work. The program was not very modular and had fseeks() and fwrites() every few lines. After a tremendous rewrite from the top down, I got the first working version up by 1981. There were several annoying bugs concerning firing broadsides and finding angles. .I Sail uses no floating point, by the way, so the direction routines are rather tricky. Ed Wang rewrote my angle() routine in 1981 to be more correct (although it still doesn't work perfectly), and he added code to let a player select which ship he wanted at the start of the game (instead of the first one available). .PP Captain Happy (Craig Leres) is responsible for making .I Sail portable for the first time. This was no easy task, by the way. Constants like 2 and 10 were very frequent in the code. I also became famous for using "Riggle Memorial Structures" in .I Sail. Many of my structure references are so long that they run off the line printer page. Here is an example, if you promise not to laugh. .br .sp .ce specs[scene[flog.fgamenum].ship[flog.fshipnum].shipnum].pts .br .sp .PP .I Sail received its fourth and most thorough rewrite in the summer and fall of 1983. Ed Wang rewrote and modularized the code (a monumental feat) almost from scratch. Although he introduced many new bugs, the final result was very much cleaner and (?) faster. He added window movement commands and find ship commands. .SH HISTORICAL INFO Old Square Riggers were very maneuverable ships capable of intricate sailing. Their only disadvantage was an inability to sail very close to the wind. The design of a wooden ship allowed only for the guns to bear to the left and right sides. A few guns of small aspect (usually 6 or 9 pounders) could point forward, but their effect was small compared to a 68 gun broadside of 24 or 32 pounders. The guns bear approximately like so: .ne 1i .nf \\ b---------------- ---0 \\ \\ \\ up to a range of ten (for round shot) \\ \\ \\ .fi An interesting phenomenon occurred when a broadside was fired down the length of an enemy ship. The shot tended to bounce along the deck and did several times more damage. This phenomenon was called a rake. Because the bows of a ship are very strong and present a smaller target than the stern, a stern rake (firing from the stern to the bow) causes more damage than a bow rake. .nf b 00 ---- Stern rake! a .fi Most ships were equipped with carronades, which were very large, close range cannons. American ships from the revolution until the War of 1812 were almost entirely armed with carronades. .PP The period of history covered in .I Sail is approximately from the 1770's until the end of Napoleonic France in 1815. There are many excellent books about the age of sail. My favorite author is Captain Frederick Marryat. More contemporary authors include C.S. Forester and Alexander Kent. .PP Fighting ships came in several sizes classed by armament. The mainstays of any fleet were its "Ships of the Line", or "Line of Battle Ships". They were so named because these ships fought together in great lines. They were close enough for mutual support, yet every ship could fire both its broadsides. We get the modern words "ocean liner," or "liner," and "battleship" from "ship of the line." The most common size was the 74 gun two decked ship of the line. The two gun decks usually mounted 18 and 24 pounder guns. .PP The pride of the fleet were the first rates. These were huge three decked ships of the line mounting 80 to 136 guns. The guns in the three tiers were usually 18, 24, and 32 pounders in that order from top to bottom. .PP Various other ships came next. They were almost all "razees," or ships of the line with one deck sawed off. They mounted 40-64 guns and were a poor cross between a frigate and a line of battle ship. They neither had the speed of the former nor the firepower of the latter. .PP Next came the "eyes of the fleet." Frigates came in many sizes mounting anywhere from 32 to 44 guns. They were very handy vessels. They could outsail anything bigger and outshoot anything smaller. Frigates didn't fight in lines of battle as the much bigger 74's did. Instead, they harassed the enemy's rear or captured crippled ships. They were much more useful in missions away from the fleet, such as cutting out expeditions or boat actions. They could hit hard and get away fast. .PP Lastly, there were the corvettes, sloops, and brigs. These were smaller ships mounting typically fewer than 20 guns. A corvette was only slightly smaller than a frigate, so one might have up to 30 guns. Sloops were used for carrying dispatches or passengers. Brigs were something you built for land-locked lakes. .SH SAIL PARTICULARS Ships in .I Sail are represented by two characters. One character represents the bow of the ship, and the other represents the stern. Ships have nationalities and numbers. The first ship of a nationality is number 0, the second number 1, etc. Therefore, the first British ship in a game would be printed as "b0". The second Brit would be "b1", and the fifth Don would be "s4". .PP Ships can set normal sails, called Battle Sails, or bend on extra canvas called Full Sails. A ship under full sail is a beautiful sight indeed, and it can move much faster than a ship under Battle Sails. The only trouble is, with full sails set, there is so much tension on sail and rigging that a well aimed round shot can burst a sail into ribbons where it would only cause a little hole in a loose sail. For this reason, rigging damage is doubled on a ship with full sails set. Don't let that discourage you from using full sails. I like to keep them up right into the heat of battle. A ship with full sails set has a capital letter for its nationality. E.g., a Frog, "f0", with full sails set would be printed as "F0". .PP When a ship is battered into a listing hulk, the last man aboard "strikes the colors." This ceremony is the ship's formal surrender. The nationality character of a surrendered ship is printed as "!". E.g., the Frog of our last example would soon be "!0". .PP A ship has a random chance of catching fire or sinking when it reaches the stage of listing hulk. A sinking ship has a "~" printed for its nationality, and a ship on fire and about to explode has a "#" printed. .PP Captured ships become the nationality of the prize crew. Therefore, if an American ship captures a British ship, the British ship will have an "a" printed for its nationality. In addition, the ship number is changed to "\*[Am]","'", "(", ,")", "*", or "+" depending upon the original number, be it 0,1,2,3,4, or 5. E.g., the "b0" captured by an American becomes the "a\*[Am]". The "s4" captured by a Frog becomes the "f*". .PP The ultimate example is, of course, an exploding Brit captured by an American: "#\*[Am]". .SH MOVEMENT Movement is the most confusing part of .I Sail to many. Ships can head in 8 directions: .nf 0 0 0 b b b0 b b b 0b b 0 0 0 .fi The stern of a ship moves when it turns. The bow remains stationary. Ships can always turn, regardless of the wind (unless they are becalmed). All ships drift when they lose headway. If a ship doesn't move forward at all for two turns, it will begin to drift. If a ship has begun to drift, then it must move forward before it turns, if it plans to do more than make a right or left turn, which is always possible. .PP Movement commands to .I Sail are a string of forward moves and turns. An example is "l3". It will turn a ship left and then move it ahead 3 spaces. In the drawing above, the "b0" made 7 successive left turns. When .I Sail prompts you for a move, it prints three characters of import. E.g., .nf move (7, 4): .fi The first number is the maximum number of moves you can make, including turns. The second number is the maximum number of turns you can make. Between the numbers is sometimes printed a quote "'". If the quote is present, it means that your ship has been drifting, and you must move ahead to regain headway before you turn (see note above). Some of the possible moves for the example above are as follows: .nf move (7, 4): 7 move (7, 4): 1 move (7, 4): d /* drift, or do nothing */ move (7, 4): 6r move (7, 4): 5r1 move (7, 4): 4r1r move (7, 4): l1r1r2 move (7, 4): 1r1r1r1 .fi Because square riggers performed so poorly sailing into the wind, if at any point in a movement command you turn into the wind, the movement stops there. E.g., .ne 1i .nf move (7, 4): l1l4 Movement Error; Helm: l1l .fi Moreover, whenever you make a turn, your movement allowance drops to min(what's left, what you would have at the new attitude). In short, if you turn closer to the wind, you most likely won't be able to sail the full allowance printed in the "move" prompt. .PP Old sailing captains had to keep an eye constantly on the wind. Captains in .I Sail are no different. A ship's ability to move depends on its attitude to the wind. The best angle possible is to have the wind off your quarter, that is, just off the stern. The direction rose on the side of the screen gives the possible movements for your ship at all positions to the wind. Battle sail speeds are given first, and full sail speeds are given in parenthesis. .nf 0 1(2) \\|/ -^-3(6) /|\\ | 4(7) 3(6) .fi Pretend the bow of your ship (the "^") is pointing upward and the wind is blowing from the bottom to the top of the page. The numbers at the bottom "3(6)" will be your speed under battle or full sails in such a situation. If the wind is off your quarter, then you can move "4(7)". If the wind is off your beam, "3(6)". If the wind is off your bow, then you can only move "1(2)". Facing into the wind, you can't move at all. Ships facing into the wind were said to be "in irons". .SH WINDSPEED AND DIRECTION The windspeed and direction is displayed as a little weather vane on the side of the screen. The number in the middle of the vane indicates the wind speed, and the + to - indicates the wind direction. The wind blows from the + sign (high pressure) to the - sign (low pressure). E.g., .nf | 3 + .fi .PP The wind speeds are 0 = becalmed, 1 = light breeze, 2 = moderate breeze, 3 = fresh breeze, 4 = strong breeze, 5 = gale, 6 = full gale, 7 = hurricane. If a hurricane shows up, all ships are destroyed. .SH GRAPPLING AND FOULING If two ships collide, they run the risk of becoming tangled together. This is called "fouling." Fouled ships are stuck together, and neither can move. They can unfoul each other if they want to. Boarding parties can only be sent across to ships when the antagonists are either fouled or grappled. .PP Ships can grapple each other by throwing grapnels into the rigging of the other. .PP The number of fouls and grapples you have are displayed on the upper right of the screen. .SH BOARDING Boarding was a very costly venture in terms of human life. Boarding parties may be formed in .I Sail to either board an enemy ship or to defend your own ship against attack. Men organized as Defensive Boarding Parties fight twice as hard to save their ship as men left unorganized. .PP The boarding strength of a crew depends upon its quality and upon the number of men sent. .SH CREW QUALITY The British seaman was world renowned for his sailing abilities. American sailors, however, were actually the best seamen in the world. Because the American Navy offered twice the wages of the Royal Navy, British seamen who liked the sea defected to America by the thousands. .PP In .I Sail, crew quality is quantized into 5 energy levels. "Elite" crews can outshoot and outfight all other sailors. "Crack" crews are next. "Mundane" crews are average, and "Green" and "Mutinous" crews are below average. A good rule of thumb is that "Crack" or "Elite" crews get one extra hit per broadside compared to "Mundane" crews. Don't expect too much from "Green" crews. .pl -1 .SH BROADSIDES Your two broadsides may be loaded with four kinds of shot: grape, chain, round, and double. You have guns and carronades in both the port and starboard batteries. Carronades only have a range of two, so you have to get in close to be able to fire them. You have the choice of firing at the hull or rigging of another ship. If the range of the ship is greater than 6, then you may only shoot at the rigging. .PP The types of shot and their advantages are: .SH ROUND Range of 10. Good for hull or rigging hits. .SH DOUBLE Range of 1. Extra good for hull or rigging hits. Double takes two turns to load. .SH CHAIN Range of 3. Excellent for tearing down rigging. Cannot damage hull or guns, though. .SH GRAPE Range of 1. Sometimes devastating against enemy crews. .PP On the side of the screen is displayed some vital information about your ship: .nf Load D! R! Hull 9 Crew 4 4 2 Guns 4 4 Carr 2 2 Rigg 5 5 5 5 .fi "Load" shows what your port (left) and starboard (right) broadsides are loaded with. A "!" after the type of shot indicates that it is an initial broadside. Initial broadside were loaded with care before battle and before the decks ran red with blood. As a consequence, initial broadsides are a little more effective than broadsides loaded later. A "*" after the type of shot indicates that the gun crews are still loading it, and you cannot fire yet. "Hull" shows how much hull you have left. "Crew" shows your three sections of crew. As your crew dies off, your ability to fire decreases. "Guns" and "Carr" show your port and starboard guns. As you lose guns, your ability to fire decreases. "Rigg" shows how much rigging you have on your 3 or 4 masts. As rigging is shot away, you lose mobility. .SH EFFECTIVENESS OF FIRE It is very dramatic when a ship fires its thunderous broadsides, but the mere opportunity to fire them does not guarantee any hits. Many factors influence the destructive force of a broadside. First of all, and the chief factor, is distance. It is harder to hit a ship at range ten than it is to hit one sloshing alongside. Next is raking. Raking fire, as mentioned before, can sometimes dismast a ship at range ten. Next, crew size and quality affects the damage done by a broadside. The number of guns firing also bears on the point, so to speak. Lastly, weather affects the accuracy of a broadside. If the seas are high (5 or 6), then the lower gunports of ships of the line can't even be opened to run out the guns. This gives frigates and other flush decked vessels an advantage in a storm. The scenario .I Pellew vs. The Droits de L'Homme takes advantage of this peculiar circumstance. .SH REPAIRS Repairs may be made to your Hull, Guns, and Rigging at the slow rate of two points per three turns. The message "Repairs Completed" will be printed if no more repairs can be made. .SH PECULIARITIES OF COMPUTER SHIPS Computer ships in .I Sail follow all the rules above with a few exceptions. Computer ships never repair damage. If they did, the players could never beat them. They play well enough as it is. As a consolation, the computer ships can fire double shot every turn. That fluke is a good reason to keep your distance. The .I Driver figures out the moves of the computer ships. It computes them with a typical A.I. distance function and a depth first search to find the maximum "score." It seems to work fairly well, although I'll be the first to admit it isn't perfect. .SH HOW TO PLAY Commands are given to .I Sail by typing a single character. You will then be prompted for further input. A brief summary of the commands follows. .br .SH COMMAND SUMMARY .nf 'f' Fire broadsides if they bear 'l' Reload 'L' Unload broadsides (to change ammo) 'm' Move 'i' Print the closest ship 'I' Print all ships 'F' Find a particular ship or ships (e.g. "a?" for all Americans) 's' Send a message around the fleet 'b' Attempt to board an enemy ship 'B' Recall boarding parties 'c' Change set of sail 'r' Repair 'u' Attempt to unfoul 'g' Grapple/ungrapple 'v' Print version number of game '^L' Redraw screen 'Q' Quit 'C' Center your ship in the window 'U' Move window up 'D','N' Move window down 'H' Move window left 'J' Move window right 'S' Toggle window to follow your ship or stay where it is .fi .bg .SH SCENARIOS Here is a summary of the scenarios in .I Sail: .br .SH Ranger vs. Drake: .nf Wind from the N, blowing a fresh breeze. (a) Ranger 19 gun Sloop (crack crew) (7 pts) (b) Drake 17 gun Sloop (crack crew) (6 pts) .SH The Battle of Flamborough Head: .nf Wind from the S, blowing a fresh breeze. .fi This is John Paul Jones' first famous battle. Aboard the Bonhomme Richard, he was able to overcome the Serapis's greater firepower by quickly boarding her. .nf (a) Bonhomme Rich 42 gun Corvette (crack crew) (11 pts) (b) Serapis 44 gun Frigate (crack crew) (12 pts) .SH Arbuthnot and Des Touches: .nf Wind from the N, blowing a gale. (b) America 64 gun Ship of the Line (crack crew) (20 pts) (b) Befford 74 gun Ship of the Line (crack crew) (26 pts) (b) Adamant 50 gun Ship of the Line (crack crew) (17 pts) (b) London 98 gun 3 Decker SOL (crack crew) (28 pts) (b) Royal Oak 74 gun Ship of the Line (crack crew) (26 pts) (f) Neptune 74 gun Ship of the Line (average crew) (24 pts) (f) Duc de Bourgogne 80 gun 3 Decker SOL (average crew) (27 pts) (f) Conquerant 74 gun Ship of the Line (average crew) (24 pts) (f) Provence 64 gun Ship of the Line (average crew) (18 pts) (f) Romulus 44 gun Ship of the Line (average crew) (10 pts) .SH Suffren and Hughes: .nf Wind from the S, blowing a fresh breeze. (b) Monmouth 74 gun Ship of the Line (average crew) (24 pts) (b) Hero 74 gun Ship of the Line (crack crew) (26 pts) (b) Isis 50 gun Ship of the Line (crack crew) (17 pts) (b) Superb 74 gun Ship of the Line (crack crew) (27 pts) (b) Burford 74 gun Ship of the Line (average crew) (24 pts) (f) Flamband 50 gun Ship of the Line (average crew) (14 pts) (f) Annibal 74 gun Ship of the Line (average crew) (24 pts) (f) Severe 64 gun Ship of the Line (average crew) (18 pts) (f) Brilliant 80 gun Ship of the Line (crack crew) (31 pts) (f) Sphinx 80 gun Ship of the Line (average crew) (27 pts) .SH Nymphe vs. Cleopatre: .nf Wind from the S, blowing a fresh breeze. (b) Nymphe 36 gun Frigate (crack crew) (11 pts) (f) Cleopatre 36 gun Frigate (average crew) (10 pts) .SH Mars vs. Hercule: Wind from the S, blowing a fresh breeze. .nf (b) Mars 74 gun Ship of the Line (crack crew) (26 pts) (f) Hercule 74 gun Ship of the Line (average crew) (23 pts) .SH Ambuscade vs. Baionnaise: .nf Wind from the N, blowing a fresh breeze. (b) Ambuscade 32 gun Frigate (average crew) (9 pts) (f) Baionnaise 24 gun Corvette (average crew) (9 pts) .SH Constellation vs. Insurgent: .nf Wind from the S, blowing a gale. (a) Constellation 38 gun Corvette (elite crew) (17 pts) (f) Insurgent 36 gun Corvette (average crew) (11 pts) .SH Constellation vs. Vengeance: .nf Wind from the S, blowing a fresh breeze. (a) Constellation 38 gun Corvette (elite crew) (17 pts) (f) Vengeance 40 gun Frigate (average crew) (15 pts) .SH The Battle of Lissa: .nf Wind from the S, blowing a fresh breeze. (b) Amphion 32 gun Frigate (elite crew) (13 pts) (b) Active 38 gun Frigate (elite crew) (18 pts) (b) Volage 22 gun Frigate (elite crew) (11 pts) (b) Cerberus 32 gun Frigate (elite crew) (13 pts) (f) Favorite 40 gun Frigate (average crew) (15 pts) (f) Flore 40 gun Frigate (average crew) (15 pts) (f) Danae 40 gun Frigate (crack crew) (17 pts) (f) Bellona 32 gun Frigate (green crew) (9 pts) (f) Corona 40 gun Frigate (green crew) (12 pts) (f) Carolina 32 gun Frigate (green crew) (7 pts) .SH Constitution vs. Guerriere: .nf Wind from the SW, blowing a gale. (a) Constitution 44 gun Corvette (elite crew) (24 pts) (b) Guerriere 38 gun Frigate (crack crew) (15 pts) .SH United States vs. Macedonian: .nf Wind from the S, blowing a fresh breeze. (a) United States 44 gun Frigate (elite crew) (24 pts) (b) Macedonian 38 gun Frigate (crack crew) (16 pts) .SH Constitution vs. Java: .nf Wind from the S, blowing a fresh breeze. (a) Constitution 44 gun Corvette (elite crew) (24 pts) (b) Java 38 gun Corvette (crack crew) (19 pts) .SH Chesapeake vs. Shannon: .nf Wind from the S, blowing a fresh breeze. (a) Chesapeake 38 gun Frigate (average crew) (14 pts) (b) Shannon 38 gun Frigate (elite crew) (17 pts) .SH The Battle of Lake Erie: .nf Wind from the S, blowing a light breeze. (a) Lawrence 20 gun Sloop (crack crew) (9 pts) (a) Niagara 20 gun Sloop (elite crew) (12 pts) (b) Lady Prevost 13 gun Brig (crack crew) (5 pts) (b) Detroit 19 gun Sloop (crack crew) (7 pts) (b) Q. Charlotte 17 gun Sloop (crack crew) (6 pts) .SH Wasp vs. Reindeer: .nf Wind from the S, blowing a light breeze. (a) Wasp 20 gun Sloop (elite crew) (12 pts) (b) Reindeer 18 gun Sloop (elite crew) (9 pts) .SH Constitution vs. Cyane and Levant: .br Wind from the S, blowing a moderate breeze. (a) Constitution 44 gun Corvette (elite crew) (24 pts) (b) Cyane 24 gun Sloop (crack crew) (11 pts) (b) Levant 20 gun Sloop (crack crew) (10 pts) .br .SH Pellew vs. Droits de L'Homme: .nf Wind from the N, blowing a gale. (b) Indefatigable 44 gun Frigate (elite crew) (14 pts) (b) Amazon 36 gun Frigate (crack crew) (14 pts) (f) Droits L'Hom 74 gun Ship of the Line (average crew) (24 pts) .SH Algeciras: .nf Wind from the SW, blowing a moderate breeze. (b) Caesar 80 gun Ship of the Line (crack crew) (31 pts) (b) Pompee 74 gun Ship of the Line (crack crew) (27 pts) (b) Spencer 74 gun Ship of the Line (crack crew) (26 pts) (b) Hannibal 98 gun 3 Decker SOL (crack crew) (28 pts) (s) Real-Carlos 112 gun 3 Decker SOL (green crew) (27 pts) (s) San Fernando 96 gun 3 Decker SOL (green crew) (24 pts) (s) Argonauta 80 gun Ship of the Line (green crew) (23 pts) (s) San Augustine 74 gun Ship of the Line (green crew) (20 pts) (f) Indomptable 80 gun Ship of the Line (average crew) (27 pts) (f) Desaix 74 gun Ship of the Line (average crew) (24 pts) .SH Lake Champlain: .nf Wind from the N, blowing a fresh breeze. (a) Saratoga 26 gun Sloop (crack crew) (12 pts) (a) Eagle 20 gun Sloop (crack crew) (11 pts) (a) Ticonderoga 17 gun Sloop (crack crew) (9 pts) (a) Preble 7 gun Brig (crack crew) (4 pts) (b) Confiance 37 gun Frigate (crack crew) (14 pts) (b) Linnet 16 gun Sloop (elite crew) (10 pts) (b) Chubb 11 gun Brig (crack crew) (5 pts) .SH Last Voyage of the USS President: .nf Wind from the N, blowing a fresh breeze. (a) President 44 gun Frigate (elite crew) (24 pts) (b) Endymion 40 gun Frigate (crack crew) (17 pts) (b) Pomone 44 gun Frigate (crack crew) (20 pts) (b) Tenedos 38 gun Frigate (crack crew) (15 pts) .SH Hornblower and the Natividad: .nf Wind from the E, blowing a gale. .fi A scenario for you Horny fans. Remember, he sank the Natividad against heavy odds and winds. Hint: don't try to board the Natividad, her crew is much bigger, albeit green. .nf (b) Lydia 36 gun Frigate (elite crew) (13 pts) (s) Natividad 50 gun Ship of the Line (green crew) (14 pts) .SH Curse of the Flying Dutchman: .nf Wind from the S, blowing a fresh breeze. Just for fun, take the Piece of cake. (s) Piece of Cake 24 gun Corvette (average crew) (9 pts) (f) Flying Dutchy 120 gun 3 Decker SOL (elite crew) (43 pts) .SH The South Pacific: .nf Wind from the S, blowing a strong breeze. (a) USS Scurvy 136 gun 3 Decker SOL (mutinous crew) (27 pts) (b) HMS Tahiti 120 gun 3 Decker SOL (elite crew) (43 pts) (s) Australian 32 gun Frigate (average crew) (9 pts) (f) Bikini Atoll 7 gun Brig (crack crew) (4 pts) .SH Hornblower and the battle of Rosas bay: .nf Wind from the E, blowing a fresh breeze. .fi The only battle Hornblower ever lost. He was able to dismast one ship and stern rake the others though. See if you can do as well. .nf (b) Sutherland 74 gun Ship of the Line (crack crew) (26 pts) (f) Turenne 80 gun 3 Decker SOL (average crew) (27 pts) (f) Nightmare 74 gun Ship of the Line (average crew) (24 pts) (f) Paris 112 gun 3 Decker SOL (green crew) (27 pts) (f) Napoleon 74 gun Ship of the Line (green crew) (20 pts) .SH Cape Horn: .nf Wind from the NE, blowing a strong breeze. (a) Concord 80 gun Ship of the Line (average crew) (27 pts) (a) Berkeley 98 gun 3 Decker SOL (crack crew) (28 pts) (b) Thames 120 gun 3 Decker SOL (elite crew) (43 pts) (s) Madrid 112 gun 3 Decker SOL (green crew) (27 pts) (f) Musket 80 gun 3 Decker SOL (average crew) (27 pts) .SH New Orleans: .nf Wind from the SE, blowing a fresh breeze. Watch that little Cypress go! (a) Alligator 120 gun 3 Decker SOL (elite crew) (43 pts) (b) Firefly 74 gun Ship of the Line (crack crew) (27 pts) (b) Cypress 44 gun Frigate (elite crew) (14 pts) .SH Botany Bay: .nf Wind from the N, blowing a fresh breeze. (b) Shark 64 gun Ship of the Line (average crew) (18 pts) (f) Coral Snake 44 gun Corvette (elite crew) (24 pts) (f) Sea Lion 44 gun Frigate (elite crew) (24 pts) .SH Voyage to the Bottom of the Sea: .nf Wind from the NW, blowing a fresh breeze. This one is dedicated to Richard Basehart and David Hedison. (a) Seaview 120 gun 3 Decker SOL (elite crew) (43 pts) (a) Flying Sub 40 gun Frigate (crack crew) (17 pts) (b) Mermaid 136 gun 3 Decker SOL (mutinous crew) (27 pts) (s) Giant Squid 112 gun 3 Decker SOL (green crew) (27 pts) .SH Frigate Action: .nf Wind from the E, blowing a fresh breeze. (a) Killdeer 40 gun Frigate (average crew) (15 pts) (b) Sandpiper 40 gun Frigate (average crew) (15 pts) (s) Curlew 38 gun Frigate (crack crew) (16 pts) .SH The Battle of Midway: .nf Wind from the E, blowing a moderate breeze. (a) Enterprise 80 gun Ship of the Line (crack crew) (31 pts) (a) Yorktown 80 gun Ship of the Line (average crew) (27 pts) (a) Hornet 74 gun Ship of the Line (average crew) (24 pts) (j) Akagi 112 gun 3 Decker SOL (green crew) (27 pts) (j) Kaga 96 gun 3 Decker SOL (green crew) (24 pts) (j) Soryu 80 gun Ship of the Line (green crew) (23 pts) .SH Star Trek: .nf Wind from the S, blowing a fresh breeze. (a) Enterprise 450 gun Ship of the Line (elite crew) (75 pts) (a) Yorktown 450 gun Ship of the Line (elite crew) (75 pts) (a) Reliant 450 gun Ship of the Line (elite crew) (75 pts) (a) Galileo 450 gun Ship of the Line (elite crew) (75 pts) (k) Kobayashi Maru 450 gun Ship of the Line (elite crew) (75 pts) (k) Klingon II 450 gun Ship of the Line (elite crew) (75 pts) (o) Red Orion 450 gun Ship of the Line (elite crew) (75 pts) (o) Blue Orion 450 gun Ship of the Line (elite crew) (75 pts) .SH CONCLUSION .I Sail has been a group effort. .SH AUTHOR Dave Riggle .SH CO-AUTHOR Ed Wang .SH REFITTING Craig Leres .SH CONSULTANTS .nf Chris Guthrie Captain Happy Horatio Nelson and many valiant others... .fi .SH REFERENCES .nf Wooden Ships \*[Am] Iron Men, by Avalon Hill Captain Horatio Hornblower Novels, (13 of them) by C.S. Forester Captain Richard Bolitho Novels, (12 of them) by Alexander Kent The Complete Works of Captain Frederick Marryat, (about 20) especially .in +6n Mr. Midshipman Easy Peter Simple Jacob Faithful Japhet in Search of a Father Snarleyyow, or The Dog Fiend Frank Mildmay, or The Naval Officer .in -6n .SH BUGS Probably a few, and please report them to "riggle@ernie.berkeley.edu" and "edward@ucbarpa.berkeley.edu" bsd-games-2.17/sail/lo_main.c0000664000175000017500000000611107767741711014531 0ustar jsm28jsm28/* $NetBSD: lo_main.c,v 1.12 2003/08/07 09:37:43 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)lo_main.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: lo_main.c,v 1.12 2003/08/07 09:37:43 agc Exp $"); #endif #endif /* not lint */ /* * Print out the top ten SAILors * * -l force a long listing (print out real usernames) */ #include #include #include #include "extern.h" #include "pathnames.h" const char *const title[] = { "Admiral", "Commodore", "Captain", "Captain", "Captain", "Captain", "Captain", "Commander", "Commander", "Lieutenant" }; int lo_main(void) { FILE *fp; char sbuf[32]; int n = 0, people; struct passwd *pass; struct logs log; struct ship *ship; if ((fp = fopen(_PATH_LOGFILE, "r")) == 0) { perror(_PATH_LOGFILE); exit(1); } switch (fread((char *)&people, sizeof people, 1, fp)) { case 0: printf("Nobody has sailed yet.\n"); exit(0); case 1: break; default: perror(_PATH_LOGFILE); exit(1); } while (fread((char *)&log, sizeof log, 1, fp) == 1 && log.l_name[0] != '\0') { if (longfmt && (pass = getpwuid(log.l_uid)) != NULL) sprintf(sbuf, "%10.10s (%s)", log.l_name, pass->pw_name); else sprintf(sbuf, "%20.20s", log.l_name); ship = &scene[log.l_gamenum].ship[log.l_shipnum]; printf("%-10s %21s of the %15s %3d points, %5.2f equiv\n", title[n++], sbuf, ship->shipname, log.l_netpoints, (float) log.l_netpoints / ship->specs->pts); } printf("\n%d people have played.\n", people); return 0; } bsd-games-2.17/sail/assorted.c0000664000175000017500000001625707767741711014753 0ustar jsm28jsm28/* $NetBSD: assorted.c,v 1.15 2003/08/07 09:37:41 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: assorted.c,v 1.15 2003/08/07 09:37:41 agc Exp $"); #endif #endif /* not lint */ #include #include #include "extern.h" static void strike (struct ship *, struct ship *); void table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int roll) { int hhits = 0, chits = 0, ghits = 0, rhits = 0; int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0; int guns, car, pc, hull; int crew[3]; int n; int rigg[4]; const char *message; const struct Tables *tp; pc = on->file->pcrew; hull = on->specs->hull; crew[0] = on->specs->crew1; crew[1] = on->specs->crew2; crew[2] = on->specs->crew3; rigg[0] = on->specs->rig1; rigg[1] = on->specs->rig2; rigg[2] = on->specs->rig3; rigg[3] = on->specs->rig4; if (shot == L_GRAPE) Chit = chits = hittable; else { tp = &(rig ? RigTable : HullTable)[hittable][roll-1]; Chit = chits = tp->C; Rhit = rhits = tp->R; Hhit = hhits = tp->H; Ghit = ghits = tp->G; if (on->file->FS) rhits *= 2; if (shot == L_CHAIN) { Ghit = ghits = 0; Hhit = hhits = 0; } } if (on->file->captured != 0) { pc -= (chits + 1) / 2; chits /= 2; } for (n = 0; n < 3; n++) if (chits > crew[n]) { chits -= crew[n]; crew[n] = 0; } else { crew[n] -= chits; chits = 0; } for (n = 0; n < 3; n++) if (rhits > rigg[n]){ rhits -= rigg[n]; rigg[n] = 0; } else { rigg[n] -= rhits; rhits = 0; } if (rigg[3] != -1 && rhits > rigg[3]) { rhits -= rigg[3]; rigg[3] = 0; } else if (rigg[3] != -1) { rigg[3] -= rhits; } if (rig && !rigg[2] && (!rigg[3] || rigg[3] == -1)) makemsg(on, "dismasted!"); if (portside(from, on, 0)) { guns = on->specs->gunR; car = on->specs->carR; } else { guns = on->specs->gunL; car = on->specs->carL; } if (ghits > car) { ghits -= car; car = 0; } else { car -= ghits; ghits = 0; } if (ghits > guns){ ghits -= guns; guns = 0; } else { guns -= ghits; ghits = 0; } hull -= ghits; if (Ghit) Write(portside(from, on, 0) ? W_GUNR : W_GUNL, on, guns, car, 0, 0); hull -= hhits; hull = hull < 0 ? 0 : hull; if (on->file->captured != 0 && Chit) Write(W_PCREW, on, pc, 0, 0, 0); if (Hhit) Write(W_HULL, on, hull, 0, 0, 0); if (Chit) Write(W_CREW, on, crew[0], crew[1], crew[2], 0); if (Rhit) Write(W_RIGG, on, rigg[0], rigg[1], rigg[2], rigg[3]); switch (shot) { case L_ROUND: message = "firing round shot on $$"; break; case L_GRAPE: message = "firing grape shot on $$"; break; case L_CHAIN: message = "firing chain shot on $$"; break; case L_DOUBLE: message = "firing double shot on $$"; break; case L_EXPLODE: message = "exploding shot on $$"; break; default: errx(1, "Unknown shot type %d", shot); } makesignal(from, message, on); if (roll == 6 && rig) { switch(Rhit) { case 0: message = "fore topsail sheets parted"; break; case 1: message = "mizzen shrouds parted"; break; case 2: message = "main topsail yard shot away"; break; case 4: message = "fore topmast and foremast shrouds shot away"; break; case 5: message = "mizzen mast and yard shot through"; break; case 6: message = "foremast and spritsail yard shattered"; break; case 7: message = "main topmast and mizzen mast shattered"; break; default: errx(1, "Bad Rhit = %d", Rhit); } makemsg(on, message); } else if (roll == 6) { switch (Hhit) { case 0: message = "anchor cables severed"; break; case 1: message = "two anchor stocks shot away"; break; case 2: message = "quarterdeck bulwarks damaged"; break; case 3: message = "three gun ports shot away"; break; case 4: message = "four guns dismounted"; break; case 5: message = "rudder cables shot through"; Write(W_TA, on, 0, 0, 0, 0); break; case 6: message = "shot holes below the water line"; break; default: errx(1, "Bad Hhit = %d", Hhit); } makemsg(on, message); } /* if (Chit > 1 && on->file->readyL&R_INITIAL && on->file->readyR&R_INITIAL) { on->specs->qual--; if (on->specs->qual <= 0) { makemsg(on, "crew mutinying!"); on->specs->qual = 5; Write(W_CAPTURED, on, on->file->index, 0, 0, 0); } else makemsg(on, "crew demoralized"); Write(W_QUAL, on, on->specs->qual, 0, 0, 0); } */ if (!hull) strike(on, from); } void Cleansnag(struct ship *from, struct ship *to, int all, int flag) { if (flag & 1) { Write(W_UNGRAP, from, to->file->index, all, 0, 0); Write(W_UNGRAP, to, from->file->index, all, 0, 0); } if (flag & 2) { Write(W_UNFOUL, from, to->file->index, all, 0, 0); Write(W_UNFOUL, to, from->file->index, all, 0, 0); } if (!snagged2(from, to)) { if (!snagged(from)) { unboard(from, from, 1); /* defense */ unboard(from, from, 0); /* defense */ } else unboard(from, to, 0); /* offense */ if (!snagged(to)) { unboard(to, to, 1); /* defense */ unboard(to, to, 0); /* defense */ } else unboard(to, from, 0); /* offense */ } } static void strike(struct ship *ship, struct ship *from) { int points; if (ship->file->struck) return; Write(W_STRUCK, ship, 1, 0, 0, 0); points = ship->specs->pts + from->file->points; Write(W_POINTS, from, points, 0, 0, 0); unboard(ship, ship, 0); /* all offense */ unboard(ship, ship, 1); /* all defense */ switch (dieroll()) { case 3: case 4: /* ship may sink */ Write(W_SINK, ship, 1, 0, 0, 0); break; case 5: case 6: /* ship may explode */ Write(W_EXPLODE, ship, 1, 0, 0, 0); break; } Writestr(W_SIGNAL, ship, "striking her colours!"); } bsd-games-2.17/sail/dr_1.c0000664000175000017500000002657010155330535013732 0ustar jsm28jsm28/* $NetBSD: dr_1.c,v 1.21 2004/11/05 21:30:32 dsl Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: dr_1.c,v 1.21 2004/11/05 21:30:32 dsl Exp $"); #endif #endif /* not lint */ #include #include #include #include #include "extern.h" #include "driver.h" static int fightitout(struct ship *, struct ship *, int); void unfoul(void) { struct ship *sp; struct ship *to; int nat; int i; foreachship(sp) { if (sp->file->captain[0]) continue; nat = capship(sp)->nationality; foreachship(to) { if (nat != capship(to)->nationality && !is_toughmelee(sp, to, 0, 0)) continue; for (i = fouled2(sp, to); --i >= 0;) if (dieroll() <= 2) cleanfoul(sp, to, 0); } } } void boardcomp(void) { int crew[3]; struct ship *sp, *sq; foreachship(sp) { if (*sp->file->captain) continue; if (sp->file->dir == 0) continue; if (sp->file->struck || sp->file->captured != 0) continue; if (!snagged(sp)) continue; crew[0] = sp->specs->crew1 != 0; crew[1] = sp->specs->crew2 != 0; crew[2] = sp->specs->crew3 != 0; foreachship(sq) { if (!Xsnagged2(sp, sq)) continue; if (meleeing(sp, sq)) continue; if (!sq->file->dir || sp->nationality == capship(sq)->nationality) continue; switch (sp->specs->class - sq->specs->class) { case -3: case -4: case -5: if (crew[0]) { /* OBP */ sendbp(sp, sq, crew[0]*100, 0); crew[0] = 0; } else if (crew[1]){ /* OBP */ sendbp(sp, sq, crew[1]*10, 0); crew[1] = 0; } break; case -2: if (crew[0] || crew[1]) { /* OBP */ sendbp(sp, sq, crew[0]*100+crew[1]*10, 0); crew[0] = crew[1] = 0; } break; case -1: case 0: case 1: if (crew[0]) { /* OBP */ sendbp(sp, sq, crew[0]*100+crew[1]*10, 0); crew[0] = crew[1] = 0; } break; case 2: case 3: case 4: case 5: /* OBP */ sendbp(sp, sq, crew[0]*100+crew[1]*10+crew[2], 0); crew[0] = crew[1] = crew[2] = 0; break; } } } } static int fightitout(struct ship *from, struct ship *to, int key) { struct ship *fromcap, *tocap; int crewfrom[3], crewto[3], menfrom, mento; int pcto, pcfrom, fromstrength, strengthto, frominjured, toinjured; int topoints; int index, totalfrom = 0, totalto = 0; int count; char message[60]; menfrom = mensent(from, to, crewfrom, &fromcap, &pcfrom, key); mento = mensent(to, from, crewto, &tocap, &pcto, 0); if (fromcap == 0) fromcap = from; if (tocap == 0) tocap = to; if (key) { if (!menfrom) { /* if crew surprised */ if (fromcap == from) menfrom = from->specs->crew1 + from->specs->crew2 + from->specs->crew3; else menfrom = from->file->pcrew; } else { menfrom *= 2; /* DBP's fight at an advantage */ } } fromstrength = menfrom * fromcap->specs->qual; strengthto = mento * tocap->specs->qual; for (count = 0; ((fromstrength < strengthto * 3 && strengthto < fromstrength * 3) || fromstrength == -1) && count < 4; count++) { index = fromstrength/10; if (index > 8) index = 8; toinjured = MT[index][2 - dieroll() / 3]; totalto += toinjured; index = strengthto/10; if (index > 8) index = 8; frominjured = MT[index][2 - dieroll() / 3]; totalfrom += frominjured; menfrom -= frominjured; mento -= toinjured; fromstrength = menfrom * fromcap->specs->qual; strengthto = mento * tocap->specs->qual; } if (fromstrength >= strengthto * 3 || count == 4) { unboard(to, from, 0); subtract(from, fromcap, totalfrom, crewfrom, pcfrom); subtract(to, tocap, totalto, crewto, pcto); makemsg(from, "boarders from %s repelled", to->shipname); sprintf(message, "killed in melee: %d. %s: %d", totalto, from->shipname, totalfrom); Writestr(W_SIGNAL, to, message); if (key) return 1; } else if (strengthto >= fromstrength * 3) { unboard(from, to, 0); subtract(from, fromcap, totalfrom, crewfrom, pcfrom); subtract(to, tocap, totalto, crewto, pcto); if (key) { if (fromcap != from) Write(W_POINTS, fromcap, fromcap->file->points - from->file->struck ? from->specs->pts : 2 * from->specs->pts, 0, 0, 0); /* ptr1 points to the shipspec for the ship that was just unboarded. I guess that what is going on here is that the pointer is multiplied or something. */ Write(W_CAPTURED, from, to->file->index, 0, 0, 0); topoints = 2 * from->specs->pts + to->file->points; if (from->file->struck) topoints -= from->specs->pts; Write(W_POINTS, to, topoints, 0, 0, 0); mento = crewto[0] ? crewto[0] : crewto[1]; if (mento) { subtract(to, tocap, mento, crewto, pcto); subtract(from, to, - mento, crewfrom, 0); } sprintf(message, "captured by the %s!", to->shipname); Writestr(W_SIGNAL, from, message); sprintf(message, "killed in melee: %d. %s: %d", totalto, from->shipname, totalfrom); Writestr(W_SIGNAL, to, message); mento = 0; return 0; } } return 0; } void resolve(void) { int thwart; struct ship *sp, *sq; foreachship(sp) { if (sp->file->dir == 0) continue; for (sq = sp + 1; sq < ls; sq++) if (sq->file->dir && meleeing(sp, sq) && meleeing(sq, sp)) fightitout(sp, sq, 0); thwart = 2; foreachship(sq) { if (sq->file->dir && meleeing(sq, sp)) thwart = fightitout(sp, sq, 1); if (!thwart) break; } if (!thwart) { foreachship(sq) { if (sq->file->dir && meleeing(sq, sp)) unboard(sq, sp, 0); unboard(sp, sq, 0); } unboard(sp, sp, 1); } else if (thwart == 2) unboard(sp, sp, 1); } } void compcombat(void) { int n; struct ship *sp; struct ship *closest; int crew[3], men = 0, target, temp; int r, guns, ready, load, car; int index, rakehim, sternrake; int shootat, hit; foreachship(sp) { if (sp->file->captain[0] || sp->file->dir == 0) continue; crew[0] = sp->specs->crew1; crew[1] = sp->specs->crew2; crew[2] = sp->specs->crew3; for (n = 0; n < 3; n++) { if (sp->file->OBP[n].turnsent) men += sp->file->OBP[n].mensent; } for (n = 0; n < 3; n++) { if (sp->file->DBP[n].turnsent) men += sp->file->DBP[n].mensent; } if (men){ crew[0] = men/100 ? 0 : crew[0] != 0; crew[1] = (men%100)/10 ? 0 : crew[1] != 0; crew[2] = men%10 ? 0 : crew[2] != 0; } for (r = 0; r < 2; r++) { if (!crew[2]) continue; if (sp->file->struck) continue; if (r) { ready = sp->file->readyR; guns = sp->specs->gunR; car = sp->specs->carR; } else { ready = sp->file->readyL; guns = sp->specs->gunL; car = sp->specs->carL; } if (!guns && !car) continue; if ((ready & R_LOADED) == 0) continue; closest = closestenemy(sp, r ? 'r' : 'l', 0); if (closest == 0) continue; if (range(closest, sp) > range(sp, closestenemy(sp, r ? 'r' : 'l', 1))) continue; if (closest->file->struck) continue; target = range(sp, closest); if (target > 10) continue; if (!guns && target >= 3) continue; load = L_ROUND; if (target == 1 && sp->file->loadwith == L_GRAPE) load = L_GRAPE; if (target <= 3 && closest->file->FS) load = L_CHAIN; if (target == 1 && load != L_GRAPE) load = L_DOUBLE; if (load > L_CHAIN && target < 6) shootat = HULL; else shootat = RIGGING; rakehim = gunsbear(sp, closest) && !gunsbear(closest, sp); temp = portside(closest, sp, 1) - closest->file->dir + 1; if (temp < 1) temp += 8; if (temp > 8) temp -= 8; sternrake = temp > 4 && temp < 6; index = guns; if (target < 3) index += car; index = (index - 1) / 3; index = index > 8 ? 8 : index; if (!rakehim) hit = HDT[index][target-1]; else hit = HDTrake[index][target-1]; if (rakehim && sternrake) hit++; hit += QUAL[index][capship(sp)->specs->qual - 1]; for (n = 0; n < 3 && sp->file->captured == 0; n++) if (!crew[n]) { if (index <= 5) hit--; else hit -= 2; } if (ready & R_INITIAL) { if (!r) sp->file->readyL &= ~R_INITIAL; else sp->file->readyR &= ~R_INITIAL; if (index <= 3) hit++; else hit += 2; } if (sp->file->captured != 0) { if (index <= 1) hit--; else hit -= 2; } hit += AMMO[index][load - 1]; temp = sp->specs->class; if ((temp >= 5 || temp == 1) && windspeed == 5) hit--; if (windspeed == 6 && temp == 4) hit -= 2; if (windspeed == 6 && temp <= 3) hit--; if (hit >= 0) { if (load != L_GRAPE) hit = hit > 10 ? 10 : hit; table(sp, closest, shootat, load, hit, dieroll()); } } } } int next(void) { if (++turn % 55 == 0) { if (alive) alive = 0; else people = 0; } if (people <= 0 || windspeed == 7) { struct ship *s; struct ship *bestship = NULL; float net, best = 0.0; foreachship(s) { if (*s->file->captain) continue; net = (float)s->file->points / s->specs->pts; if (net > best) { best = net; bestship = s; } } if (best > 0.0) { char *tp = getenv("WOTD"); const char *p; if (tp == 0) p = "Driver"; else { *tp = toupper((unsigned char)*tp); p = tp; } strlcpy(bestship->file->captain, p, sizeof bestship->file->captain); logger(bestship); } return -1; } Write(W_TURN, SHIP(0), turn, 0, 0, 0); if (turn % 7 == 0 && (dieroll() >= cc->windchange || !windspeed)) { switch (dieroll()) { case 1: winddir = 1; break; case 2: break; case 3: winddir++; break; case 4: winddir--; break; case 5: winddir += 2; break; case 6: winddir -= 2; break; } if (winddir > 8) winddir -= 8; if (winddir < 1) winddir += 8; if (windspeed) switch (dieroll()) { case 1: case 2: windspeed--; break; case 5: case 6: windspeed++; break; } else windspeed++; Write(W_WIND, SHIP(0), winddir, windspeed, 0, 0); } return 0; } bsd-games-2.17/sail/dr_2.c0000664000175000017500000001626707767741711013756 0ustar jsm28jsm28/* $NetBSD: dr_2.c,v 1.19 2003/08/07 09:37:41 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: dr_2.c,v 1.19 2003/08/07 09:37:41 agc Exp $"); #endif #endif /* not lint */ #include #include #include #include "extern.h" #include "driver.h" #define couldwin(f,t) (f->specs->crew2 > t->specs->crew2 * 1.5) static int str_end(const char *); static int score(struct ship *, struct ship *, char *, int); static void move_ship(struct ship *, const char *, unsigned char *, short *, short *, char *); static void try(struct ship *, struct ship *, char *, char *, int, int, int, int, int, int *, int); static void rmend(char *); const int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */ void thinkofgrapples(void) { struct ship *sp, *sq; char friendly; foreachship(sp) { if (sp->file->captain[0] || sp->file->dir == 0) continue; foreachship(sq) { friendly = sp->nationality == capship(sq)->nationality; if (!friendly) { if (sp->file->struck || sp->file->captured != 0) continue; if (range(sp, sq) != 1) continue; if (grappled2(sp, sq)) if (is_toughmelee(sp, sq, 0, 0)) ungrap(sp, sq); else grap(sp, sq); else if (couldwin(sp, sq)) { grap(sp, sq); sp->file->loadwith = L_GRAPE; } } else ungrap(sp, sq); } } } void checkup(void) { struct ship *sp, *sq; char explode, sink; foreachship(sp) { if (sp->file->dir == 0) continue; explode = sp->file->explode; sink = sp->file->sink; if (explode != 1 && sink != 1) continue; if (dieroll() < 5) continue; Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 2, 0, 0, 0); Write(W_DIR, sp, 0, 0, 0, 0); if (snagged(sp)) foreachship(sq) cleansnag(sp, sq, 1); if (sink != 1) { makemsg(sp, "exploding!"); foreachship(sq) { if (sp != sq && sq->file->dir && range(sp, sq) < 4) table(sp, sq, RIGGING, L_EXPLODE, sp->specs->guns/13, 6); } } else makemsg(sp, "sinking!"); } } void prizecheck(void) { struct ship *sp; foreachship(sp) { if (sp->file->captured == 0) continue; if (sp->file->struck || sp->file->dir == 0) continue; if (sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3 > sp->file->pcrew * 6) { Writestr(W_SIGNAL, sp, "prize crew overthrown"); Write(W_POINTS, sp->file->captured, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0); Write(W_CAPTURED, sp, -1, 0, 0, 0); } } } static int str_end(const char *str) { const char *p; for (p = str; *p; p++) ; return p == str ? 0 : p[-1]; } void closeon(struct ship *from, struct ship *to, char *command, int ta, int ma, int af) { int high; char temp[10]; temp[0] = command[0] = '\0'; high = -30000; try(from, to, command, temp, ma, ta, af, ma, from->file->dir, &high, 0); } static int score(struct ship *ship, struct ship *to, char *movement, int onlytemp) { char drift; int row, col, dir, total, ran; struct File *fp = ship->file; if ((dir = fp->dir) == 0) return 0; row = fp->row; col = fp->col; drift = fp->drift; move_ship(ship, movement, &fp->dir, &fp->row, &fp->col, &drift); if (!*movement) strcpy(movement, "d"); ran = range(ship, to); total = -50 * ran; if (ran < 4 && gunsbear(ship, to)) total += 60; if ((ran = portside(ship, to, 1) - fp->dir) == 4 || ran == -4) total = -30000; if (!onlytemp) { fp->row = row; fp->col = col; fp->dir = dir; } return total; } static void move_ship(struct ship *ship, const char *p, unsigned char *dir, short *row, short *col, char *drift) { int dist; char moved = 0; for (; *p; p++) { switch (*p) { case 'r': if (++*dir == 9) *dir = 1; break; case 'l': if (--*dir == 0) *dir = 8; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': moved++; if (*dir % 2 == 0) dist = dtab[*p - '0']; else dist = *p - '0'; *row -= dr[*dir] * dist; *col -= dc[*dir] * dist; break; } } if (!moved) { if (windspeed != 0 && ++*drift > 2) { if ((ship->specs->class >= 3 && !snagged(ship)) || (turn & 1) == 0) { *row -= dr[winddir]; *col -= dc[winddir]; } } } else *drift = 0; } static void try(struct ship *f, struct ship *t, char *command, char *temp, int ma, int ta, int af, int vma, int dir, int *high, int rakeme) { int new, n; char st[4]; #define rakeyou (gunsbear(f, t) && !gunsbear(t, f)) if ((n = str_end(temp)) < '1' || n > '9') for (n = 1; vma - n >= 0; n++) { sprintf(st, "%d", n); strcat(temp, st); new = score(f, t, temp, rakeme); if (new > *high && (!rakeme || rakeyou)) { *high = new; strcpy(command, temp); } try(f, t, command, temp, ma-n, ta, af, vma-n, dir, high, rakeme); rmend(temp); } if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) { strcat(temp, "r"); new = score(f, t, temp, rakeme); if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) { *high = new; strcpy(command, temp); } try(f, t, command, temp, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1), high, rakeme); rmend(temp); } if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){ strcat(temp, "l"); new = score(f, t, temp, rakeme); if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))){ *high = new; strcpy(command, temp); } try(f, t, command, temp, ma-1, ta-1, af, (min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))), (dir-1 ? dir -1 : 8), high, rakeme); rmend(temp); } } static void rmend(char *str) { char *p; for (p = str; *p; p++) ; if (p != str) *--p = 0; } bsd-games-2.17/sail/dr_3.c0000664000175000017500000002013307767741711013742 0ustar jsm28jsm28/* $NetBSD: dr_3.c,v 1.15 2003/08/07 09:37:42 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: dr_3.c,v 1.15 2003/08/07 09:37:42 agc Exp $"); #endif #endif /* not lint */ #include #include #include "extern.h" #include "driver.h" static int stillmoving(int); static int is_isolated(struct ship *); static int push(struct ship *, struct ship *); static void step(struct ship *, int, char *); /* move all comp ships */ void moveall(void) { struct ship *sp, *sq; int n; int k, l; int row[NSHIP], col[NSHIP], dir[NSHIP], drift[NSHIP]; char moved[NSHIP]; /* * first try to create moves for OUR ships */ foreachship(sp) { struct ship *closest; int ma, ta; char af; if (sp->file->captain[0] || sp->file->dir == 0) continue; if (!sp->file->struck && windspeed && !snagged(sp) && sp->specs->crew3) { ta = maxturns(sp, &af); ma = maxmove(sp, sp->file->dir, 0); closest = closestenemy(sp, 0, 0); if (closest == 0) *sp->file->movebuf = '\0'; else closeon(sp, closest, sp->file->movebuf, ta, ma, af); } else *sp->file->movebuf = '\0'; } /* * Then execute the moves for ALL ships (dead ones too), * checking for collisions and snags at each step. * The old positions are saved in row[], col[], dir[]. * At the end, we compare and write out the changes. */ n = 0; foreachship(sp) { if (snagged(sp)) strcpy(sp->file->movebuf, "d"); else if (*sp->file->movebuf != 'd') strcat(sp->file->movebuf, "d"); row[n] = sp->file->row; col[n] = sp->file->col; dir[n] = sp->file->dir; drift[n] = sp->file->drift; moved[n] = 0; n++; } /* * Now resolve collisions. * This is the tough part. */ for (k = 0; stillmoving(k); k++) { /* * Step once. * And propagate the nulls at the end of sp->file->movebuf. */ n = 0; foreachship(sp) { if (!sp->file->movebuf[k]) sp->file->movebuf[k+1] = '\0'; else if (sp->file->dir) step(sp, sp->file->movebuf[k], &moved[n]); n++; } /* * The real stuff. */ n = 0; foreachship(sp) { if (sp->file->dir == 0 || is_isolated(sp)) goto cont1; l = 0; foreachship(sq) { char snap = 0; if (sp == sq) goto cont2; if (sq->file->dir == 0) goto cont2; if (!push(sp, sq)) goto cont2; if (snagged2(sp, sq) && range(sp, sq) > 1) snap++; if (!range(sp, sq) && !fouled2(sp, sq)) { makesignal(sp, "collision with $$", sq); if (dieroll() < 4) { makesignal(sp, "fouled with $$", sq); Write(W_FOUL, sp, l, 0, 0, 0); Write(W_FOUL, sq, n, 0, 0, 0); } snap++; } if (snap) { sp->file->movebuf[k + 1] = 0; sq->file->movebuf[k + 1] = 0; sq->file->row = sp->file->row - 1; if (sp->file->dir == 1 || sp->file->dir == 5) sq->file->col = sp->file->col - 1; else sq->file->col = sp->file->col; sq->file->dir = sp->file->dir; } cont2: l++; } cont1: n++; } } /* * Clear old moves. And write out new pos. */ n = 0; foreachship(sp) { if (sp->file->dir != 0) { *sp->file->movebuf = 0; if (row[n] != sp->file->row) Write(W_ROW, sp, sp->file->row, 0, 0, 0); if (col[n] != sp->file->col) Write(W_COL, sp, sp->file->col, 0, 0, 0); if (dir[n] != sp->file->dir) Write(W_DIR, sp, sp->file->dir, 0, 0, 0); if (drift[n] != sp->file->drift) Write(W_DRIFT, sp, sp->file->drift, 0, 0, 0); } n++; } } static int stillmoving(int k) { struct ship *sp; foreachship(sp) if (sp->file->movebuf[k]) return 1; return 0; } static int is_isolated(struct ship *ship) { struct ship *sp; foreachship(sp) { if (ship != sp && range(ship, sp) <= 10) return 0; } return 1; } static int push(struct ship *from, struct ship *to) { int bs, sb; sb = to->specs->guns; bs = from->specs->guns; if (sb > bs) return 1; if (sb < bs) return 0; return from < to; } static void step(struct ship *sp, int com, char *moved) { int dist; switch (com) { case 'r': if (++sp->file->dir == 9) sp->file->dir = 1; break; case 'l': if (--sp->file->dir == 0) sp->file->dir = 8; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': if (sp->file->dir % 2 == 0) dist = dtab[com - '0']; else dist = com - '0'; sp->file->row -= dr[sp->file->dir] * dist; sp->file->col -= dc[sp->file->dir] * dist; *moved = 1; break; case 'b': break; case 'd': if (!*moved) { if (windspeed != 0 && ++sp->file->drift > 2 && ((sp->specs->class >= 3 && !snagged(sp)) || (turn & 1) == 0)) { sp->file->row -= dr[winddir]; sp->file->col -= dc[winddir]; } } else sp->file->drift = 0; break; } } void sendbp(struct ship *from, struct ship *to, int sections, int isdefense) { int n; struct BP *bp; bp = isdefense ? from->file->DBP : from->file->OBP; for (n = 0; n < NBP && bp[n].turnsent; n++) ; if (n < NBP && sections) { Write(isdefense ? W_DBP : W_OBP, from, n, turn, to->file->index, sections); if (isdefense) makemsg(from, "repelling boarders"); else makesignal(from, "boarding the $$", to); } } int is_toughmelee(struct ship *ship, struct ship *to, int isdefense, int count) { struct BP *bp; int obp = 0; int n, OBP = 0, DBP = 0, dbp = 0; int qual; qual = ship->specs->qual; bp = isdefense ? ship->file->DBP : ship->file->OBP; for (n = 0; n < NBP; n++, bp++) { if (bp->turnsent && (to == bp->toship || isdefense)) { obp += bp->mensent / 100 ? ship->specs->crew1 * qual : 0; obp += (bp->mensent % 100)/10 ? ship->specs->crew2 * qual : 0; obp += bp->mensent % 10 ? ship->specs->crew3 * qual : 0; } } if (count || isdefense) return obp; OBP = is_toughmelee(to, ship, 0, count + 1); dbp = is_toughmelee(ship, to, 1, count + 1); DBP = is_toughmelee(to, ship, 1, count + 1); if (OBP > obp + 10 || OBP + DBP >= obp + dbp + 10) return 1; else return 0; } void reload(void) { struct ship *sp; foreachship(sp) { sp->file->loadwith = 0; } } void checksails(void) { struct ship *sp; int rig, full; struct ship *close; foreachship(sp) { if (sp->file->captain[0] != 0) continue; rig = sp->specs->rig1; if (windspeed == 6 || (windspeed == 5 && sp->specs->class > 4)) rig = 0; if (rig && sp->specs->crew3) { close = closestenemy(sp, 0, 0); if (close != 0) { if (range(sp, close) > 9) full = 1; else full = 0; } else full = 0; } else full = 0; if ((sp->file->FS != 0) != full) Write(W_FS, sp, full, 0, 0, 0); } } bsd-games-2.17/sail/dr_4.c0000664000175000017500000000470207767741711013747 0ustar jsm28jsm28/* $NetBSD: dr_4.c,v 1.13 2003/08/07 09:37:42 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)dr_4.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: dr_4.c,v 1.13 2003/08/07 09:37:42 agc Exp $"); #endif #endif /* not lint */ #include #include "extern.h" void ungrap(struct ship *from, struct ship *to) { int k; char friend; if ((k = grappled2(from, to)) == 0) return; friend = capship(from)->nationality == capship(to)->nationality; while (--k >= 0) { if (friend || dieroll() < 3) { cleangrapple(from, to, 0); makesignal(from, "ungrappling $$", to); } } } void grap(struct ship *from, struct ship *to) { if (capship(from)->nationality != capship(to)->nationality && dieroll() > 2) return; Write(W_GRAP, from, to->file->index, 0, 0, 0); Write(W_GRAP, to, from->file->index, 0, 0, 0); makesignal(from, "grappled with $$", to); } bsd-games-2.17/sail/dr_5.c0000664000175000017500000000612707767741711013753 0ustar jsm28jsm28/* $NetBSD: dr_5.c,v 1.12 2003/08/07 09:37:42 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: dr_5.c,v 1.12 2003/08/07 09:37:42 agc Exp $"); #endif #endif /* not lint */ #include #include "extern.h" void subtract(struct ship *from, struct ship *fromcap, int totalfrom, int *crewfrom, int pcfrom) { int n; if (fromcap == from && totalfrom) { /* if not captured */ for (n = 0; n < 3; n++) { if (totalfrom > crewfrom[n]) { totalfrom -= crewfrom[n]; crewfrom[n] = 0; } else { crewfrom[n] -= totalfrom; totalfrom = 0; } } Write(W_CREW, from, crewfrom[0], crewfrom[1], crewfrom[2], 0); } else if (totalfrom) { pcfrom -= totalfrom; pcfrom = pcfrom < 0 ? 0 : pcfrom; Write(W_PCREW, from, pcfrom, 0, 0, 0); } } int mensent(struct ship *from, struct ship *to, int *crew, struct ship **captured, int *pc, int isdefense) { /* returns # of crew squares sent */ int men = 0; int n; int c1, c2, c3; struct BP *bp; *pc = from->file->pcrew; *captured = from->file->captured; crew[0] = from->specs->crew1; crew[1] = from->specs->crew2; crew[2] = from->specs->crew3; bp = isdefense ? from->file->DBP : from->file->OBP; for (n=0; n < NBP; n++, bp++) { if (bp->turnsent && bp->toship == to) men += bp->mensent; } if (men) { c1 = men/100 ? crew[0] : 0; c2 = (men%100)/10 ? crew[1] : 0; c3 = men/10 ? crew[2] : 0; c3 = *captured == 0 ? crew[2] : *pc; } else c1 = c2 = c3 = 0; return(c1 + c2 + c3); } bsd-games-2.17/sail/pl_1.c0000664000175000017500000000744610005547567013752 0ustar jsm28jsm28/* $NetBSD: pl_1.c,v 1.18 2004/01/27 20:23:36 jsm Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)pl_1.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pl_1.c,v 1.18 2004/01/27 20:23:36 jsm Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include "extern.h" #include "player.h" /* * If we get here before a ship is chosen, then ms == 0 and * we don't want to update the score file, or do any Write's either. * We can assume the sync file is already created and may need * to be removed. * Of course, we don't do any more Sync()'s if we got here * because of a Sync() failure. */ void leave(int conditions) { signal(SIGHUP, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGALRM, SIG_IGN); signal(SIGCHLD, SIG_IGN); if (done_curses) { Msg("It looks like you've had it!"); switch (conditions) { case LEAVE_QUIT: break; case LEAVE_CAPTURED: Msg("Your ship was captured."); break; case LEAVE_HURRICAN: Msg("Hurricane! All ships destroyed."); break; case LEAVE_DRIVER: Msg("The driver died."); break; case LEAVE_SYNC: Msg("Synchronization error."); break; default: Msg("A funny thing happened (%d).", conditions); } } else { switch (conditions) { case LEAVE_QUIT: break; case LEAVE_DRIVER: printf("The driver died.\n"); break; case LEAVE_FORK: perror("fork"); break; case LEAVE_SYNC: printf("Synchronization error\n."); break; default: printf("A funny thing happened (%d).\n", conditions); } } if (ms != 0) { logger(ms); if (conditions != LEAVE_SYNC) { makemsg(ms, "Captain %s relinquishing.", mf->captain); Write(W_END, ms, 0, 0, 0, 0); Sync(); } } sync_close(!hasdriver); sleep(5); cleanupscreen(); exit(0); } /*ARGSUSED*/ void choke(int n __attribute__((__unused__))) { leave(LEAVE_QUIT); } /*ARGSUSED*/ void child(int n __attribute__((__unused__))) { int status; int pid; signal(SIGCHLD, SIG_IGN); do { pid = wait3(&status, WNOHANG, (struct rusage *)0); if (pid < 0 || (pid > 0 && !WIFSTOPPED(status))) hasdriver = 0; } while (pid > 0); signal(SIGCHLD, child); } bsd-games-2.17/sail/pl_2.c0000664000175000017500000000720607767741711013755 0ustar jsm28jsm28/* $NetBSD: pl_2.c,v 1.11 2003/08/07 09:37:43 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)pl_2.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pl_2.c,v 1.11 2003/08/07 09:37:43 agc Exp $"); #endif #endif /* not lint */ #include #include "extern.h" #include "player.h" void play(void) { struct ship *sp; for (;;) { switch (sgetch("~\b", (struct ship *)0, 0)) { case 'm': acceptmove(); break; case 's': acceptsignal(); break; case 'g': grapungrap(); break; case 'u': unfoulplayer(); break; case 'v': Msg("%s", version); break; case 'b': acceptboard(); break; case 'f': acceptcombat(); break; case 'l': loadplayer(); break; case 'c': changesail(); break; case 'r': repair(); break; case 'B': Msg("'Hands to stations!'"); unboard(ms, ms, 1); /* cancel DBP's */ unboard(ms, ms, 0); /* cancel offense */ break; case '\f': centerview(); blockalarm(); draw_board(); draw_screen(); unblockalarm(); break; case 'L': mf->loadL = L_EMPTY; mf->loadR = L_EMPTY; mf->readyL = R_EMPTY; mf->readyR = R_EMPTY; Msg("Broadsides unloaded"); break; case 'q': Msg("Type 'Q' to quit"); break; case 'Q': leave(LEAVE_QUIT); break; case 'I': foreachship(sp) if (sp != ms) eyeball(sp); break; case 'i': if ((sp = closestenemy(ms, 0, 1)) == 0) Msg("No more ships left."); else eyeball(sp); break; case 'C': centerview(); blockalarm(); draw_view(); unblockalarm(); break; case 'U': upview(); blockalarm(); draw_view(); unblockalarm(); break; case 'D': case 'N': downview(); blockalarm(); draw_view(); unblockalarm(); break; case 'H': leftview(); blockalarm(); draw_view(); unblockalarm(); break; case 'J': rightview(); blockalarm(); draw_view(); unblockalarm(); break; case 'F': lookout(); break; case 'S': dont_adjust = !dont_adjust; blockalarm(); draw_turn(); unblockalarm(); break; } } } bsd-games-2.17/sail/pl_3.c0000664000175000017500000001551307767741711013756 0ustar jsm28jsm28/* $NetBSD: pl_3.c,v 1.17 2003/08/07 09:37:43 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pl_3.c,v 1.17 2003/08/07 09:37:43 agc Exp $"); #endif #endif /* not lint */ #include #include #include "extern.h" #include "player.h" void acceptcombat(void) { int men = 0; int target, temp; int n, r; int index, rakehim, sternrake; int hhits = 0, ghits = 0, rhits = 0, chits = 0; int crew[3]; int load; int guns, car, ready, shootat, hit; int roll; struct ship *closest; crew[0] = mc->crew1; crew[1] = mc->crew2; crew[2] = mc->crew3; for (n = 0; n < 3; n++) { if (mf->OBP[n].turnsent) men += mf->OBP[n].mensent; } for (n = 0; n < 3; n++) { if (mf->DBP[n].turnsent) men += mf->DBP[n].mensent; } if (men) { crew[0] = men/100 ? 0 : crew[0] != 0; crew[1] = (men%100)/10 ? 0 : crew[1] != 0; crew[2] = men%10 ? 0 : crew[2] != 0; } for (r = 0; r < 2; r++) { if (r) { ready = mf->readyR; load = mf->loadR; guns = mc->gunR; car = mc->carR; } else { ready = mf->readyL; load = mf->loadL; guns = mc->gunL; car = mc->carL; } if ((!guns && !car) || load == L_EMPTY || (ready & R_LOADED) == 0) goto cant; if (mf->struck || !crew[2]) goto cant; closest = closestenemy(ms, (r ? 'r' : 'l'), 1); if (closest == 0) goto cant; if (closest->file->struck) goto cant; target = range(ms, closest); if (target > rangeofshot[load] || (!guns && target >= 3)) goto cant; Signal("$$ within range of %s broadside.", closest, r ? "right" : "left"); if (load > L_CHAIN && target < 6) { switch (sgetch("Aim for hull or rigging? ", (struct ship *)0, 1)) { case 'r': shootat = RIGGING; break; case 'h': shootat = HULL; break; default: shootat = -1; Msg("'Avast there! Hold your fire.'"); } } else { if (sgetch("Fire? ", (struct ship *)0, 1) == 'n') { shootat = -1; Msg("Belay that! Hold your fire."); } else shootat = RIGGING; } if (shootat == -1) continue; fired = 1; rakehim = gunsbear(ms, closest) && !gunsbear(closest, ms); temp = portside(closest, ms, 1) - closest->file->dir + 1; if (temp < 1) temp += 8; else if (temp > 8) temp -= 8; sternrake = temp > 4 && temp < 6; if (rakehim) { if (!sternrake) Msg("Raking the %s!", closest->shipname); else Msg("Stern Rake! %s splintering!", closest->shipname); } index = guns; if (target < 3) index += car; index = (index - 1)/3; index = index > 8 ? 8 : index; if (!rakehim) hit = HDT[index][target-1]; else hit = HDTrake[index][target-1]; if (rakehim && sternrake) hit++; hit += QUAL[index][mc->qual-1]; for (n = 0; n < 3 && mf->captured == 0; n++) if (!crew[n]) { if (index <= 5) hit--; else hit -= 2; } if (ready & R_INITIAL) { if (index <= 3) hit++; else hit += 2; } if (mf->captured != 0) { if (index <= 1) hit--; else hit -= 2; } hit += AMMO[index][load - 1]; if (((temp = mc->class) >= 5 || temp == 1) && windspeed == 5) hit--; if (windspeed == 6 && temp == 4) hit -= 2; if (windspeed == 6 && temp <= 3) hit--; if (hit >= 0) { roll = dieroll(); if (load == L_GRAPE) chits = hit; else { const struct Tables *t; if (hit > 10) hit = 10; t = &(shootat == RIGGING ? RigTable : HullTable) [hit][roll-1]; chits = t->C; rhits = t->R; hhits = t->H; ghits = t->G; if (closest->file->FS) rhits *= 2; if (load == L_CHAIN) { ghits = 0; hhits = 0; } } table(ms, closest, shootat, load, hit, roll); } Msg("Damage inflicted on the %s:", closest->shipname); Msg("\t%d HULL, %d GUNS, %d CREW, %d RIGGING", hhits, ghits, chits, rhits); if (!r) { mf->loadL = L_EMPTY; mf->readyL = R_EMPTY; } else { mf->loadR = L_EMPTY; mf->readyR = R_EMPTY; } continue; cant: Msg("Unable to fire %s broadside", r ? "right" : "left"); } blockalarm(); draw_stat(); unblockalarm(); } void grapungrap(void) { struct ship *sp; int i; foreachship(sp) { if (sp == ms || sp->file->dir == 0) continue; if (range(ms, sp) > 1 && !grappled2(ms, sp)) continue; switch (sgetch("Attempt to grapple or ungrapple $$: ", sp, 1)) { case 'g': if (dieroll() < 3 || ms->nationality == capship(sp)->nationality) { Write(W_GRAP, ms, sp->file->index, 0, 0, 0); Write(W_GRAP, sp, player, 0, 0, 0); Msg("Attempt succeeds!"); makesignal(ms, "grappled with $$", sp); } else Msg("Attempt fails."); break; case 'u': for (i = grappled2(ms, sp); --i >= 0;) { if (ms->nationality == capship(sp)->nationality || dieroll() < 3) { cleangrapple(ms, sp, 0); Msg("Attempt succeeds!"); makesignal(ms, "ungrappling with $$", sp); } else Msg("Attempt fails."); } break; } } } void unfoulplayer(void) { struct ship *to; int i; foreachship(to) { if (fouled2(ms, to) == 0) continue; if (sgetch("Attempt to unfoul with the $$? ", to, 1) != 'y') continue; for (i = fouled2(ms, to); --i >= 0;) { if (dieroll() <= 2) { cleanfoul(ms, to, 0); Msg("Attempt succeeds!"); makesignal(ms, "Unfouling $$", to); } else Msg("Attempt fails."); } } } bsd-games-2.17/sail/pl_4.c0000664000175000017500000000702210155330535013732 0ustar jsm28jsm28/* $NetBSD: pl_4.c,v 1.15 2004/11/05 21:30:32 dsl Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)pl_4.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pl_4.c,v 1.15 2004/11/05 21:30:32 dsl Exp $"); #endif #endif /* not lint */ #include #include #include "extern.h" #include "player.h" void changesail(void) { int rig, full; rig = mc->rig1; full = mf->FS; if (windspeed == 6 || (windspeed == 5 && mc->class > 4)) rig = 0; if (mc->crew3 && rig) { if (!full) { if (sgetch("Increase to Full sails? ", (struct ship *)0, 1) == 'y') { changed = 1; Write(W_FS, ms, 1, 0, 0, 0); } } else { if (sgetch("Reduce to Battle sails? ", (struct ship *)0, 1) == 'y') { Write(W_FS, ms, 0, 0, 0, 0); changed = 1; } } } else if (!rig) Msg("Sails rent to pieces"); } void acceptsignal(void) { char buf[60]; char *p = buf; *p++ = '"'; sgetstr("Message? ", p, sizeof buf - 2); while (*p++) ; p[-1] = '"'; *p = 0; Writestr(W_SIGNAL, ms, buf); } void lookout(void) { struct ship *sp; char buf[3]; char c; sgetstr("What ship? ", buf, sizeof buf); foreachship(sp) { c = *countryname[sp->nationality]; if ((tolower((unsigned char)c) == *buf || colours(sp) == *buf) && (sp->file->stern == buf[1] || sterncolour(sp) == buf[1] || buf[1] == '?')) { eyeball(sp); } } } const char * saywhat(struct ship *sp, int flag) { if (sp->file->captain[0]) return sp->file->captain; else if (sp->file->struck) return "(struck)"; else if (sp->file->captured != 0) return "(captured)"; else if (flag) return "(available)"; else return "(computer)"; } void eyeball(struct ship *ship) { int i; if (ship->file->dir != 0) { Msg("Sail ho! (range %d, %s)", range(ms, ship), saywhat(ship, 0)); i = portside(ms, ship, 1) - mf->dir; if (i <= 0) i += 8; Signal("$$ %s %s %s.", ship, countryname[ship->nationality], classname[ship->specs->class], directionname[i]); } } bsd-games-2.17/sail/pl_5.c0000664000175000017500000001447710155330535013747 0ustar jsm28jsm28/* $NetBSD: pl_5.c,v 1.17 2004/11/05 21:30:32 dsl Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pl_5.c,v 1.17 2004/11/05 21:30:32 dsl Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include "extern.h" #include "player.h" #include "display.h" #define turnfirst(x) (*x == 'r' || *x == 'l') static void parties(struct ship *, int *, int, int); void acceptmove(void) { int ta; int ma; char af; int moved = 0; int vma, dir; char prompt[60]; char buf[60], last = '\0'; char *p; if (!mc->crew3 || snagged(ms) || !windspeed) { Msg("Unable to move"); return; } ta = maxturns(ms, &af); ma = maxmove(ms, mf->dir, 0); sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta); sgetstr(prompt, buf, sizeof buf); dir = mf->dir; vma = ma; for (p = buf; *p; p++) switch (*p) { case 'l': dir -= 2; case 'r': if (++dir == 0) dir = 8; else if (dir == 9) dir = 1; if (last == 't') { Msg("Ship can't turn that fast."); *p-- = '\0'; } last = 't'; ma--; ta--; vma = min(ma, maxmove(ms, dir, 0)); if ((ta < 0 && moved) || (vma < 0 && moved)) *p-- = '\0'; break; case 'b': ma--; vma--; last = 'b'; if ((ta < 0 && moved) || (vma < 0 && moved)) *p-- = '\0'; break; case '0': case 'd': *p-- = '\0'; break; case '\n': *p-- = '\0'; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': if (last == '0') { Msg("Can't move that fast."); *p-- = '\0'; } last = '0'; moved = 1; ma -= *p - '0'; vma -= *p - '0'; if ((ta < 0 && moved) || (vma < 0 && moved)) *p-- = '\0'; break; default: if (!isspace((unsigned char)*p)) { Msg("Input error."); *p-- = '\0'; } } if ((ta < 0 && moved) || (vma < 0 && moved) || (af && turnfirst(buf) && moved)) { Msg("Movement error."); if (ta < 0 && moved) { if (mf->FS == 1) { Write(W_FS, ms, 0, 0, 0, 0); Msg("No hands to set full sails."); } } else if (ma >= 0) buf[1] = '\0'; } if (af && !moved) { if (mf->FS == 1) { Write(W_FS, ms, 0, 0, 0, 0); Msg("No hands to set full sails."); } } if (*buf) strcpy(movebuf, buf); else strcpy(movebuf, "d"); Writestr(W_MOVE, ms, movebuf); Msg("Helm: %s.", movebuf); } void acceptboard(void) { struct ship *sp; int n; int crew[3]; int men = 0; char c; crew[0] = mc->crew1; crew[1] = mc->crew2; crew[2] = mc->crew3; for (n = 0; n < NBP; n++) { if (mf->OBP[n].turnsent) men += mf->OBP[n].mensent; } for (n = 0; n < NBP; n++) { if (mf->DBP[n].turnsent) men += mf->DBP[n].mensent; } if (men) { crew[0] = men/100 ? 0 : crew[0] != 0; crew[1] = (men%100)/10 ? 0 : crew[1] != 0; crew[2] = men%10 ? 0 : crew[2] != 0; } else { crew[0] = crew[0] != 0; crew[1] = crew[1] != 0; crew[2] = crew[2] != 0; } foreachship(sp) { if (sp == ms || sp->file->dir == 0 || range(ms, sp) > 1) continue; if (ms->nationality == capship(sp)->nationality) continue; if (meleeing(ms, sp) && crew[2]) { c = sgetch("How many more to board the $$? ", sp, 1); parties(sp, crew, 0, c); } else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) { c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1); parties(sp, crew, 0, c); } } if (crew[2]) { c = sgetch("How many sections to repel boarders? ", (struct ship *)0, 1); parties(ms, crew, 1, c); } blockalarm(); draw_slot(); unblockalarm(); } static void parties(struct ship *to, int *crew, int isdefense, int buf) { int k, j, men; struct BP *ptr; int temp[3]; for (k = 0; k < 3; k++) temp[k] = crew[k]; if (isdigit(buf)) { ptr = isdefense ? to->file->DBP : to->file->OBP; for (j = 0; j < NBP && ptr[j].turnsent; j++) ; if (!ptr[j].turnsent && buf > '0') { men = 0; for (k = 0; k < 3 && buf > '0'; k++) { men += crew[k] * (k == 0 ? 100 : (k == 1 ? 10 : 1)); crew[k] = 0; if (men) buf--; } if (buf > '0') Msg("Sending all crew sections."); Write(isdefense ? W_DBP : W_OBP, ms, j, turn, to->file->index, men); if (isdefense) { wmove(slot_w, 2, 0); for (k=0; k < NBP; k++) if (temp[k] && !crew[k]) waddch(slot_w, k + '1'); else wmove(slot_w, 2, 1 + k); mvwaddstr(slot_w, 3, 0, "DBP"); makemsg(ms, "repelling boarders"); } else { wmove(slot_w, 0, 0); for (k=0; k < NBP; k++) if (temp[k] && !crew[k]) waddch(slot_w, k + '1'); else wmove(slot_w, 0, 1 + k); mvwaddstr(slot_w, 1, 0, "OBP"); makesignal(ms, "boarding the $$", to); } blockalarm(); wrefresh(slot_w); unblockalarm(); } else Msg("Sending no crew sections."); } } bsd-games-2.17/sail/pl_6.c0000664000175000017500000001125507767741711013760 0ustar jsm28jsm28/* $NetBSD: pl_6.c,v 1.11 2003/08/07 09:37:44 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)pl_6.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pl_6.c,v 1.11 2003/08/07 09:37:44 agc Exp $"); #endif #endif /* not lint */ #include #include "extern.h" #include "player.h" static int turned(void); void repair(void) { char c; char *repairs; struct shipspecs *ptr = mc; int count; #define FIX(x, m) (m - ptr->x > count \ ? (ptr->x += count, count = 0) : (count -= m - ptr->x, ptr->x = m)) if (repaired || loaded || fired || changed || turned()) { Msg("No hands free to repair"); return; } c = sgetch("Repair (hull, guns, rigging)? ", (struct ship *)0, 1); switch (c) { case 'h': repairs = &mf->RH; break; case 'g': repairs = &mf->RG; break; case 'r': repairs = &mf->RR; break; default: Msg("Avast heaving!"); return; } if (++*repairs >= 3) { count = 2; switch (c) { case 'h': { int max = ptr->guns/4; if (ptr->hull < max) { FIX(hull, max); Write(W_HULL, ms, ptr->hull, 0, 0, 0); } break; } case 'g': if (ptr->gunL < ptr->gunR) { int max = ptr->guns/5 - ptr->carL; if (ptr->gunL < max) { FIX(gunL, max); Write(W_GUNL, ms, ptr->gunL, ptr->carL, 0, 0); } } else { int max = ptr->guns/5 - ptr->carR; if (ptr->gunR < max) { FIX(gunR, max); Write(W_GUNR, ms, ptr->gunR, ptr->carR, 0, 0); } } break; case 'r': #define X 2 if (ptr->rig4 >= 0 && ptr->rig4 < X) { FIX(rig4, X); Write(W_RIG4, ms, ptr->rig4, 0, 0, 0); } if (count && ptr->rig3 < X) { FIX(rig3, X); Write(W_RIG3, ms, ptr->rig3, 0, 0, 0); } if (count && ptr->rig2 < X) { FIX(rig2, X); Write(W_RIG2, ms, ptr->rig2, 0, 0, 0); } if (count && ptr->rig1 < X) { FIX(rig1, X); Write(W_RIG1, ms, ptr->rig1, 0, 0, 0); } break; } if (count == 2) { Msg("Repairs completed."); *repairs = 2; } else { *repairs = 0; blockalarm(); draw_stat(); unblockalarm(); } } blockalarm(); draw_slot(); unblockalarm(); repaired = 1; } static int turned(void) { char *p; for (p = movebuf; *p; p++) if (*p == 'r' || *p == 'l') return 1; return 0; } void loadplayer(void) { char c; int loadL, loadR, ready, load; if (!mc->crew3) { Msg("Out of crew"); return; } loadL = mf->loadL; loadR = mf->loadR; if (!loadL && !loadR) { c = sgetch("Load which broadside (left or right)? ", (struct ship *)0, 1); if (c == 'r') loadL = 1; else loadR = 1; } if ((!loadL && loadR) || (loadL && !loadR)) { c = sgetch("Reload with (round, double, chain, grape)? ", (struct ship *)0, 1); switch (c) { case 'r': load = L_ROUND; ready = 0; break; case 'd': load = L_DOUBLE; ready = R_DOUBLE; break; case 'c': load = L_CHAIN; ready = 0; break; case 'g': load = L_GRAPE; ready = 0; break; default: Msg("Broadside not loaded."); return; } if (!loadR) { mf->loadR = load; mf->readyR = ready|R_LOADING; } else { mf->loadL = load; mf->readyL = ready|R_LOADING; } loaded = 1; } } bsd-games-2.17/sail/driver.h0000664000175000017500000000327207767741711014420 0ustar jsm28jsm28/* $NetBSD: driver.h,v 1.8 2003/08/07 09:37:42 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)driver.h 8.2 (Berkeley) 5/3/95 */ extern const int dtab[]; bsd-games-2.17/sail/player.h0000664000175000017500000000661607767741711014426 0ustar jsm28jsm28/* $NetBSD: player.h,v 1.11 2003/08/07 09:37:44 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)player.h 8.2 (Berkeley) 5/3/95 */ /* sizes and coordinates for the screen */ #define LINE_T 0 #define LINE_L 0 #define LINE_X COLS #define LINE_Y 1 #define LINE_B (LINE_T+LINE_Y-1) #define LINE_R (LINE_L+LINE_X-1) #define BOX_T 1 #define BOX_L 0 #define BOX_X 65 #define BOX_Y 16 #define BOX_B (BOX_T+BOX_Y-1) #define BOX_R (BOX_L+BOX_X-1) #define TURN_T BOX_B #define TURN_Y 1 #define TURN_L ((BOX_L+BOX_R-TURN_X)/2) #define TURN_X 9 #define TURN_B (TURN_T+TURN_Y+1) #define TURN_R (TURN_L+TURN_X+1) #define STAT_T 0 #define STAT_B BOX_B #define STAT_L (BOX_R+2) #define STAT_X 14 #define STAT_Y (STAT_B-STAT_T+1) #define STAT_R (STAT_L+STAT_X-1) #define STAT_1 0 #define STAT_2 (STAT_1+4) #define STAT_3 (STAT_2+7) #define SCROLL_T (BOX_B+1) #define SCROLL_L 0 #define SCROLL_B (LINES-1) #define SCROLL_R (COLS-1) #define SCROLL_X (SCROLL_R-SCROLL_L+1) #define SCROLL_Y (SCROLL_B-SCROLL_T+1) #define VIEW_T (BOX_T+1) #define VIEW_L (BOX_L+1) #define VIEW_X (BOX_X-5) #define VIEW_Y (BOX_Y-2) #define VIEW_B (VIEW_T+VIEW_Y-1) #define VIEW_R (VIEW_L+VIEW_X-1) #define SLOT_T VIEW_T #define SLOT_L (VIEW_R+1) #define SLOT_X 3 #define SLOT_Y VIEW_Y #define SLOT_B VIEW_B #define SLOT_R (SLOT_L+SLOT_X-1) extern int done_curses; extern int loaded, fired, changed, repaired; extern int dont_adjust; extern int viewrow, viewcol; extern char movebuf[sizeof SHIP(0)->file->movebuf]; extern char version[]; extern int player; extern struct ship *ms; /* memorial structure, &cc->ship[player] */ extern struct File *mf; /* ms->file */ extern struct shipspecs *mc; /* ms->specs */ /* condition codes for leave() */ #define LEAVE_QUIT 0 #define LEAVE_CAPTURED 1 #define LEAVE_HURRICAN 2 #define LEAVE_DRIVER 3 #define LEAVE_FORK 4 #define LEAVE_SYNC 5 bsd-games-2.17/sail/pl_7.c0000664000175000017500000002540207767741711013760 0ustar jsm28jsm28/* $NetBSD: pl_7.c,v 1.27 2003/08/07 09:37:44 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)pl_7.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pl_7.c,v 1.27 2003/08/07 09:37:44 agc Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include "extern.h" #include "player.h" #include "display.h" static void Scroll(void); static void endprompt(int); static void adjustview(void); /* * Display interface */ static char sc_hasprompt; static const char *sc_prompt; static const char *sc_buf; static int sc_line; WINDOW *view_w; WINDOW *slot_w; WINDOW *scroll_w; WINDOW *stat_w; WINDOW *turn_w; int done_curses; int loaded, fired, changed, repaired; int dont_adjust; int viewrow, viewcol; char movebuf[sizeof SHIP(0)->file->movebuf]; int player; struct ship *ms; /* memorial structure, &cc->ship[player] */ struct File *mf; /* ms->file */ struct shipspecs *mc; /* ms->specs */ void initscreen(void) { if (!SCREENTEST()) { printf("Can't sail on this terminal.\n"); exit(1); } /* initscr() already done in SCREENTEST() */ view_w = newwin(VIEW_Y, VIEW_X, VIEW_T, VIEW_L); slot_w = newwin(SLOT_Y, SLOT_X, SLOT_T, SLOT_L); scroll_w = newwin(SCROLL_Y, SCROLL_X, SCROLL_T, SCROLL_L); stat_w = newwin(STAT_Y, STAT_X, STAT_T, STAT_L); turn_w = newwin(TURN_Y, TURN_X, TURN_T, TURN_L); done_curses++; leaveok(view_w, 1); leaveok(slot_w, 1); leaveok(stat_w, 1); leaveok(turn_w, 1); noecho(); cbreak(); } void cleanupscreen(void) { /* alarm already turned off */ if (done_curses) { wmove(scroll_w, SCROLL_Y - 1, 0); wclrtoeol(scroll_w); draw_screen(); endwin(); } } /*ARGSUSED*/ void newturn(int n __attribute__((__unused__))) { repaired = loaded = fired = changed = 0; movebuf[0] = '\0'; alarm(0); if (mf->readyL & R_LOADING) { if (mf->readyL & R_DOUBLE) mf->readyL = R_LOADING; else mf->readyL = R_LOADED; } if (mf->readyR & R_LOADING) { if (mf->readyR & R_DOUBLE) mf->readyR = R_LOADING; else mf->readyR = R_LOADED; } if (!hasdriver) Write(W_DDEAD, SHIP(0), 0, 0, 0, 0); if (sc_hasprompt) { wmove(scroll_w, sc_line, 0); wclrtoeol(scroll_w); } if (Sync() < 0) leave(LEAVE_SYNC); if (!hasdriver) leave(LEAVE_DRIVER); if (sc_hasprompt) wprintw(scroll_w, "%s%s", sc_prompt, sc_buf); if (turn % 50 == 0) Write(W_ALIVE, SHIP(0), 0, 0, 0, 0); if (mf->FS && (!mc->rig1 || windspeed == 6)) Write(W_FS, ms, 0, 0, 0, 0); if (mf->FS == 1) Write(W_FS, ms, 2, 0, 0, 0); if (mf->struck) leave(LEAVE_QUIT); if (mf->captured != 0) leave(LEAVE_CAPTURED); if (windspeed == 7) leave(LEAVE_HURRICAN); adjustview(); draw_screen(); signal(SIGALRM, newturn); alarm(7); } /*VARARGS2*/ void Signal(const char *fmt, struct ship *ship, ...) { va_list ap; char format[BUFSIZ]; if (!done_curses) return; va_start(ap, ship); if (*fmt == '\7') putchar(*fmt++); fmtship(format, sizeof(format), fmt, ship); vwprintw(scroll_w, format, ap); va_end(ap); Scroll(); } /*VARARGS2*/ void Msg(const char *fmt, ...) { va_list ap; if (!done_curses) return; va_start(ap, fmt); if (*fmt == '\7') putchar(*fmt++); vwprintw(scroll_w, fmt, ap); va_end(ap); Scroll(); } static void Scroll(void) { if (++sc_line >= SCROLL_Y) sc_line = 0; wmove(scroll_w, sc_line, 0); wclrtoeol(scroll_w); } void prompt(const char *p, struct ship *ship) { static char buf[BUFSIZ]; fmtship(buf, sizeof(buf), p, ship); sc_prompt = buf; sc_buf = ""; sc_hasprompt = 1; waddstr(scroll_w, buf); } static void endprompt(int flag) { sc_hasprompt = 0; if (flag) Scroll(); } int sgetch(const char *p, struct ship *ship, int flag) { int c; prompt(p, ship); blockalarm(); wrefresh(scroll_w); unblockalarm(); while ((c = wgetch(scroll_w)) == EOF) ; if (flag && c >= ' ' && c < 0x7f) waddch(scroll_w, c); endprompt(flag); return c; } void sgetstr(const char *pr, char *buf, int n) { int c; char *p = buf; prompt(pr, (struct ship *)0); sc_buf = buf; for (;;) { *p = 0; blockalarm(); wrefresh(scroll_w); unblockalarm(); while ((c = wgetch(scroll_w)) == EOF) ; switch (c) { case '\n': case '\r': endprompt(1); return; case '\b': if (p > buf) { waddstr(scroll_w, "\b \b"); p--; } break; default: if (c >= ' ' && c < 0x7f && p < buf + n - 1) { *p++ = c; waddch(scroll_w, c); } else putchar('\a'); } } } void draw_screen(void) { draw_view(); draw_turn(); draw_stat(); draw_slot(); wrefresh(scroll_w); /* move the cursor */ } void draw_view(void) { struct ship *sp; werase(view_w); foreachship(sp) { if (sp->file->dir && sp->file->row > viewrow && sp->file->row < viewrow + VIEW_Y && sp->file->col > viewcol && sp->file->col < viewcol + VIEW_X) { wmove(view_w, sp->file->row - viewrow, sp->file->col - viewcol); waddch(view_w, colours(sp)); wmove(view_w, sternrow(sp) - viewrow, sterncol(sp) - viewcol); waddch(view_w, sterncolour(sp)); } } wrefresh(view_w); } void draw_turn(void) { wmove(turn_w, 0, 0); wprintw(turn_w, "%cTurn %d", dont_adjust?'*':'-', turn); wrefresh(turn_w); } void draw_stat(void) { wmove(stat_w, STAT_1, 0); wprintw(stat_w, "Points %3d\n", mf->points); wprintw(stat_w, "Fouls %2d\n", fouled(ms)); wprintw(stat_w, "Grapples %2d\n", grappled(ms)); wmove(stat_w, STAT_2, 0); wprintw(stat_w, " 0 %c(%c)\n", maxmove(ms, winddir + 3, -1) + '0', maxmove(ms, winddir + 3, 1) + '0'); waddstr(stat_w, " \\|/\n"); wprintw(stat_w, " -^-%c(%c)\n", maxmove(ms, winddir + 2, -1) + '0', maxmove(ms, winddir + 2, 1) + '0'); waddstr(stat_w, " /|\\\n"); wprintw(stat_w, " | %c(%c)\n", maxmove(ms, winddir + 1, -1) + '0', maxmove(ms, winddir + 1, 1) + '0'); wprintw(stat_w, " %c(%c)\n", maxmove(ms, winddir, -1) + '0', maxmove(ms, winddir, 1) + '0'); wmove(stat_w, STAT_3, 0); wprintw(stat_w, "Load %c%c %c%c\n", loadname[mf->loadL], readyname(mf->readyL), loadname[mf->loadR], readyname(mf->readyR)); wprintw(stat_w, "Hull %2d\n", mc->hull); wprintw(stat_w, "Crew %2d %2d %2d\n", mc->crew1, mc->crew2, mc->crew3); wprintw(stat_w, "Guns %2d %2d\n", mc->gunL, mc->gunR); wprintw(stat_w, "Carr %2d %2d\n", mc->carL, mc->carR); wprintw(stat_w, "Rigg %d %d %d ", mc->rig1, mc->rig2, mc->rig3); if (mc->rig4 < 0) waddch(stat_w, '-'); else wprintw(stat_w, "%d", mc->rig4); wrefresh(stat_w); } void draw_slot(void) { if (!boarding(ms, 0)) { mvwaddstr(slot_w, 0, 0, " "); mvwaddstr(slot_w, 1, 0, " "); } else mvwaddstr(slot_w, 1, 0, "OBP"); if (!boarding(ms, 1)) { mvwaddstr(slot_w, 2, 0, " "); mvwaddstr(slot_w, 3, 0, " "); } else mvwaddstr(slot_w, 3, 0, "DBP"); wmove(slot_w, SLOT_Y-4, 0); if (mf->RH) wprintw(slot_w, "%dRH", mf->RH); else waddstr(slot_w, " "); wmove(slot_w, SLOT_Y-3, 0); if (mf->RG) wprintw(slot_w, "%dRG", mf->RG); else waddstr(slot_w, " "); wmove(slot_w, SLOT_Y-2, 0); if (mf->RR) wprintw(slot_w, "%dRR", mf->RR); else waddstr(slot_w, " "); #define Y (SLOT_Y/2) wmove(slot_w, 7, 1); wprintw(slot_w,"%d", windspeed); mvwaddch(slot_w, Y, 0, ' '); mvwaddch(slot_w, Y, 2, ' '); mvwaddch(slot_w, Y-1, 0, ' '); mvwaddch(slot_w, Y-1, 1, ' '); mvwaddch(slot_w, Y-1, 2, ' '); mvwaddch(slot_w, Y+1, 0, ' '); mvwaddch(slot_w, Y+1, 1, ' '); mvwaddch(slot_w, Y+1, 2, ' '); wmove(slot_w, Y - dr[winddir], 1 - dc[winddir]); switch (winddir) { case 1: case 5: waddch(slot_w, '|'); break; case 2: case 6: waddch(slot_w, '/'); break; case 3: case 7: waddch(slot_w, '-'); break; case 4: case 8: waddch(slot_w, '\\'); break; } mvwaddch(slot_w, Y + dr[winddir], 1 + dc[winddir], '+'); wrefresh(slot_w); } void draw_board(void) { int n; clear(); werase(view_w); werase(slot_w); werase(scroll_w); werase(stat_w); werase(turn_w); sc_line = 0; move(BOX_T, BOX_L); for (n = 0; n < BOX_X; n++) addch('-'); move(BOX_B, BOX_L); for (n = 0; n < BOX_X; n++) addch('-'); for (n = BOX_T+1; n < BOX_B; n++) { mvaddch(n, BOX_L, '|'); mvaddch(n, BOX_R, '|'); } mvaddch(BOX_T, BOX_L, '+'); mvaddch(BOX_T, BOX_R, '+'); mvaddch(BOX_B, BOX_L, '+'); mvaddch(BOX_B, BOX_R, '+'); refresh(); #define WSaIM "Wooden Ships & Iron Men" wmove(view_w, 2, (VIEW_X - sizeof WSaIM - 1) / 2); waddstr(view_w, WSaIM); wmove(view_w, 4, (VIEW_X - strlen(cc->name)) / 2); waddstr(view_w, cc->name); wrefresh(view_w); move(LINE_T, LINE_L); printw("Class %d %s (%d guns) '%s' (%c%c)", mc->class, classname[mc->class], mc->guns, ms->shipname, colours(ms), sterncolour(ms)); refresh(); } void centerview(void) { viewrow = mf->row - VIEW_Y / 2; viewcol = mf->col - VIEW_X / 2; } void upview(void) { viewrow -= VIEW_Y / 3; } void downview(void) { viewrow += VIEW_Y / 3; } void leftview(void) { viewcol -= VIEW_X / 5; } void rightview(void) { viewcol += VIEW_X / 5; } static void adjustview(void) { if (dont_adjust) return; if (mf->row < viewrow + VIEW_Y/4) viewrow = mf->row - (VIEW_Y - VIEW_Y/4); else if (mf->row > viewrow + (VIEW_Y - VIEW_Y/4)) viewrow = mf->row - VIEW_Y/4; if (mf->col < viewcol + VIEW_X/8) viewcol = mf->col - (VIEW_X - VIEW_X/8); else if (mf->col > viewcol + (VIEW_X - VIEW_X/8)) viewcol = mf->col - VIEW_X/8; } bsd-games-2.17/sail/machdep.h0000664000175000017500000000417507767741711014531 0ustar jsm28jsm28/* $NetBSD: machdep.h,v 1.5 2003/08/07 09:37:43 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)machdep.h 8.1 (Berkeley) 5/31/93 */ #define TIMEOUT 300 /* Sync() timeout in seconds */ /* for POSIX systems */ #define blockalarm() \ do { \ sigset_t sigset; \ sigemptyset(&sigset); \ sigaddset(&sigset, SIGALRM); \ sigprocmask(SIG_BLOCK, &sigset, (sigset_t *)0); \ } while (0) #define unblockalarm() \ do { \ sigset_t sigset; \ sigemptyset(&sigset); \ sigaddset(&sigset, SIGALRM); \ sigprocmask(SIG_UNBLOCK, &sigset, (sigset_t *)0); \ } while (0) bsd-games-2.17/sail/dr_main.c0000664000175000017500000000635507767741711014536 0ustar jsm28jsm28/* $NetBSD: dr_main.c,v 1.12 2003/08/07 09:37:42 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)dr_main.c 8.2 (Berkeley) 4/16/94"; #else __RCSID("$NetBSD: dr_main.c,v 1.12 2003/08/07 09:37:42 agc Exp $"); #endif #endif /* not lint */ #include #include #include #include #include "extern.h" #include "driver.h" int dr_main(void) { int n; struct ship *sp; int nat[NNATION]; int value = 0; signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGTSTP, SIG_IGN); if (game < 0 || game >= NSCENE) { fprintf(stderr, "DRIVER: Bad game number %d\n", game); exit(1); } cc = &scene[game]; ls = SHIP(cc->vessels); if (sync_open() < 0) { perror("driver: syncfile"); exit(1); } for (n = 0; n < NNATION; n++) nat[n] = 0; foreachship(sp) { if (sp->file == NULL && (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) { fprintf(stderr, "DRIVER: Out of memory.\n"); exit(1); } sp->file->index = sp - SHIP(0); sp->file->loadL = L_ROUND; sp->file->loadR = L_ROUND; sp->file->readyR = R_LOADED|R_INITIAL; sp->file->readyL = R_LOADED|R_INITIAL; sp->file->stern = nat[sp->nationality]++; sp->file->dir = sp->shipdir; sp->file->row = sp->shiprow; sp->file->col = sp->shipcol; } windspeed = cc->windspeed; winddir = cc->winddir; people = 0; for (;;) { sleep(7); if (Sync() < 0) { value = 1; break; } if (next() < 0) break; unfoul(); checkup(); prizecheck(); moveall(); thinkofgrapples(); boardcomp(); compcombat(); resolve(); reload(); checksails(); if (Sync() < 0) { value = 1; break; } } sync_close(1); return value; } bsd-games-2.17/sail/game.c0000664000175000017500000000574007767741711014033 0ustar jsm28jsm28/* $NetBSD: game.c,v 1.11 2003/08/07 09:37:42 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)game.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: game.c,v 1.11 2003/08/07 09:37:42 agc Exp $"); #endif #endif /* not lint */ #include #include "extern.h" int maxturns(struct ship *ship, char *af) { int turns; turns = ship->specs->ta; *af = (ship->file->drift > 1 && turns); if (*af != '\0') { turns--; if (ship->file->FS == 1) turns = 0; } return turns; } int maxmove(struct ship *ship, int dir, int fs) { int riggone = 0, Move, flank = 0; Move = ship->specs->bs; if (!ship->specs->rig1) riggone++; if (!ship->specs->rig2) riggone++; if (!ship->specs->rig3) riggone++; if (!ship->specs->rig4) riggone++; if ((ship->file->FS || fs) && fs != -1) { flank = 1; Move = ship->specs->fs; } if (dir == winddir) Move -= 1 + WET[windspeed][ship->specs->class-1].B; else if (dir == winddir + 2 || dir == winddir - 2 || dir == winddir - 6 || dir == winddir + 6) Move -= 1 + WET[windspeed][ship->specs->class-1].C; else if (dir == winddir + 3 || dir == winddir - 3 || dir == winddir - 5 || dir == winddir + 5) Move = (flank ? 2 : 1) - WET[windspeed][ship->specs->class-1].D; else if (dir == winddir + 4 || dir == winddir - 4) Move = 0; else Move -= WET[windspeed][ship->specs->class-1].A; Move -= riggone; Move = Move < 0 ? 0 : Move; return(Move); } bsd-games-2.17/sail/sync.c0000664000175000017500000002352510117543602014055 0ustar jsm28jsm28/* $NetBSD: sync.c,v 1.23 2004/09/07 13:20:39 jrf Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: sync.c,v 1.23 2004/09/07 13:20:39 jrf Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include "extern.h" #include "pathnames.h" #define BUFSIZE 4096 static int sync_update(int, struct ship *, const char *, long, long, long, long); static const char SF[] = _PATH_SYNC; static const char LF[] = _PATH_LOCK; static char sync_buf[BUFSIZE]; static char *sync_bp = sync_buf; static char sync_lock[sizeof SF]; static char sync_file[sizeof LF]; static long sync_seek; static FILE *sync_fp; void fmtship(char *buf, size_t len, const char *fmt, struct ship *ship) { while (*fmt) { if (len-- == 0) { *buf = '\0'; return; } if (*fmt == '$' && fmt[1] == '$') { size_t l = snprintf(buf, len, "%s (%c%c)", ship->shipname, colours(ship), sterncolour(ship)); buf += l; len -= l - 1; fmt += 2; } else *buf++ = *fmt++; } if (len > 0) *buf = '\0'; } /*VARARGS3*/ void makesignal(struct ship *from, const char *fmt, struct ship *ship, ...) { char message[BUFSIZ]; char format[BUFSIZ]; va_list ap; va_start(ap, ship); fmtship(format, sizeof(format), fmt, ship); vsprintf(message, format, ap); va_end(ap); Writestr(W_SIGNAL, from, message); } /*VARARGS2*/ void makemsg(struct ship *from, const char *fmt, ...) { char message[BUFSIZ]; va_list ap; va_start(ap, fmt); vsprintf(message, fmt, ap); va_end(ap); Writestr(W_SIGNAL, from, message); } int sync_exists(int game) { char buf[sizeof sync_file]; struct stat s; time_t t; sprintf(buf, SF, game); time(&t); setegid(egid); if (stat(buf, &s) < 0) { setegid(gid); return 0; } if (s.st_mtime < t - 60*60*2) { /* 2 hours */ unlink(buf); sprintf(buf, LF, game); unlink(buf); setegid(gid); return 0; } else { setegid(gid); return 1; } } int sync_open(void) { struct stat tmp; if (sync_fp != NULL) fclose(sync_fp); sprintf(sync_lock, LF, game); sprintf(sync_file, SF, game); setegid(egid); if (stat(sync_file, &tmp) < 0) { mode_t omask = umask(002); sync_fp = fopen(sync_file, "w+"); umask(omask); } else sync_fp = fopen(sync_file, "r+"); setegid(gid); if (sync_fp == NULL) return -1; sync_seek = 0; return 0; } void sync_close(int remove) { if (sync_fp != 0) fclose(sync_fp); if (remove) { setegid(egid); unlink(sync_file); setegid(gid); } } void Write(int type, struct ship *ship, long a, long b, long c, long d) { sprintf(sync_bp, "%d %d 0 %ld %ld %ld %ld\n", type, ship->file->index, a, b, c, d); while (*sync_bp++) ; sync_bp--; if (sync_bp >= &sync_buf[sizeof sync_buf]) abort(); sync_update(type, ship, NULL, a, b, c, d); } void Writestr(int type, struct ship *ship, const char *a) { sprintf(sync_bp, "%d %d 1 %s\n", type, ship->file->index, a); while (*sync_bp++) ; sync_bp--; if (sync_bp >= &sync_buf[sizeof sync_buf]) abort(); sync_update(type, ship, a, 0, 0, 0, 0); } int Sync(void) { sig_t sighup, sigint; int n; int type, shipnum, isstr; char *astr; long a, b, c, d; char buf[80]; char erred = 0; sighup = signal(SIGHUP, SIG_IGN); sigint = signal(SIGINT, SIG_IGN); for (n = TIMEOUT; --n >= 0;) { #ifdef LOCK_EX if (flock(fileno(sync_fp), LOCK_EX|LOCK_NB) >= 0) break; if (errno != EWOULDBLOCK) return -1; #else setegid(egid); if (link(sync_file, sync_lock) >= 0) { setegid(gid); break; } setegid(gid); if (errno != EEXIST) return -1; #endif sleep(1); } if (n <= 0) return -1; fseek(sync_fp, sync_seek, SEEK_SET); for (;;) { switch (fscanf(sync_fp, "%d%d%d", &type, &shipnum, &isstr)) { case 3: break; case EOF: goto out; default: goto bad; } if (shipnum < 0 || shipnum >= cc->vessels) goto bad; if (isstr != 0 && isstr != 1) goto bad; if (isstr) { char *p; for (p = buf;;) { switch (*p++ = getc(sync_fp)) { case '\n': p--; case EOF: break; default: if (p >= buf + sizeof buf) p--; continue; } break; } *p = 0; for (p = buf; *p == ' '; p++) ; astr = p; a = b = c = d = 0; } else { if (fscanf(sync_fp, "%ld%ld%ld%ld", &a, &b, &c, &d) != 4) goto bad; astr = NULL; } if (sync_update(type, SHIP(shipnum), astr, a, b, c, d) < 0) goto bad; } bad: erred++; out: if (!erred && sync_bp != sync_buf) { fseek(sync_fp, 0L, SEEK_END); fwrite(sync_buf, sizeof *sync_buf, sync_bp - sync_buf, sync_fp); fflush(sync_fp); sync_bp = sync_buf; } sync_seek = ftell(sync_fp); #ifdef LOCK_EX flock(fileno(sync_fp), LOCK_UN); #else setegid(egid); unlink(sync_lock); setegid(gid); #endif signal(SIGHUP, sighup); signal(SIGINT, sigint); return erred ? -1 : 0; } static int sync_update(int type, struct ship *ship, const char *astr, long a, long b, long c, long d) { switch (type) { case W_DBP: { struct BP *p = &ship->file->DBP[a]; p->turnsent = b; p->toship = SHIP(c); p->mensent = d; break; } case W_OBP: { struct BP *p = &ship->file->OBP[a]; p->turnsent = b; p->toship = SHIP(c); p->mensent = d; break; } case W_FOUL: { struct snag *p = &ship->file->foul[a]; if (SHIP(a)->file->dir == 0) break; if (p->sn_count++ == 0) p->sn_turn = turn; ship->file->nfoul++; break; } case W_GRAP: { struct snag *p = &ship->file->grap[a]; if (SHIP(a)->file->dir == 0) break; if (p->sn_count++ == 0) p->sn_turn = turn; ship->file->ngrap++; break; } case W_UNFOUL: { struct snag *p = &ship->file->foul[a]; if (p->sn_count > 0) { if (b) { ship->file->nfoul -= p->sn_count; p->sn_count = 0; } else { ship->file->nfoul--; p->sn_count--; } } break; } case W_UNGRAP: { struct snag *p = &ship->file->grap[a]; if (p->sn_count > 0) { if (b) { ship->file->ngrap -= p->sn_count; p->sn_count = 0; } else { ship->file->ngrap--; p->sn_count--; } } break; } case W_SIGNAL: if (mode == MODE_PLAYER) { if (nobells) Signal("$$: %s", ship, astr); else Signal("\7$$: %s", ship, astr); } break; case W_CREW: { struct shipspecs *s = ship->specs; s->crew1 = a; s->crew2 = b; s->crew3 = c; break; } case W_CAPTAIN: strlcpy(ship->file->captain, astr, sizeof ship->file->captain); break; case W_CAPTURED: if (a < 0) ship->file->captured = 0; else ship->file->captured = SHIP(a); break; case W_CLASS: ship->specs->class = a; break; case W_DRIFT: ship->file->drift = a; break; case W_EXPLODE: if ((ship->file->explode = a) == 2) ship->file->dir = 0; break; case W_FS: ship->file->FS = a; break; case W_GUNL: { struct shipspecs *s = ship->specs; s->gunL = a; s->carL = b; break; } case W_GUNR: { struct shipspecs *s = ship->specs; s->gunR = a; s->carR = b; break; } case W_HULL: ship->specs->hull = a; break; case W_MOVE: strlcpy(ship->file->movebuf, astr, sizeof ship->file->movebuf); break; case W_PCREW: ship->file->pcrew = a; break; case W_POINTS: ship->file->points = a; break; case W_QUAL: ship->specs->qual = a; break; case W_RIGG: { struct shipspecs *s = ship->specs; s->rig1 = a; s->rig2 = b; s->rig3 = c; s->rig4 = d; break; } case W_RIG1: ship->specs->rig1 = a; break; case W_RIG2: ship->specs->rig2 = a; break; case W_RIG3: ship->specs->rig3 = a; break; case W_RIG4: ship->specs->rig4 = a; break; case W_COL: ship->file->col = a; break; case W_DIR: ship->file->dir = a; break; case W_ROW: ship->file->row = a; break; case W_SINK: if ((ship->file->sink = a) == 2) ship->file->dir = 0; break; case W_STRUCK: ship->file->struck = a; break; case W_TA: ship->specs->ta = a; break; case W_ALIVE: alive = 1; break; case W_TURN: turn = a; break; case W_WIND: winddir = a; windspeed = b; break; case W_BEGIN: strcpy(ship->file->captain, "begin"); people++; break; case W_END: *ship->file->captain = 0; ship->file->points = 0; people--; break; case W_DDEAD: hasdriver = 0; break; default: fprintf(stderr, "sync_update: unknown type %d\r\n", type); return -1; } return 0; } bsd-games-2.17/sail/pl_main.c0000664000175000017500000001404307767741711014535 0ustar jsm28jsm28/* $NetBSD: pl_main.c,v 1.16 2003/08/07 09:37:44 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)pl_main.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pl_main.c,v 1.16 2003/08/07 09:37:44 agc Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include "extern.h" #include "player.h" #include "restart.h" static void initialize(void); /*ARGSUSED*/ int pl_main(void) { initialize(); Msg("Aye aye, Sir"); play(); return 0; /* for lint, play() never returns */ } static void initialize(void) { struct File *fp; struct ship *sp; char captain[80]; char message[60]; int load; int n; char *nameptr; int nat[NNATION]; if (game < 0) { puts("Choose a scenario:\n"); puts("\n\tNUMBER\tSHIPS\tIN PLAY\tTITLE"); for (n = 0; n < NSCENE; n++) { /* ( */ printf("\t%d):\t%d\t%s\t%s\n", n, scene[n].vessels, sync_exists(n) ? "YES" : "no", scene[n].name); } reprint: printf("\nScenario number? "); fflush(stdout); scanf("%d", &game); while (getchar() != '\n') ; } if (game < 0 || game >= NSCENE) { puts("Very funny."); exit(1); } cc = &scene[game]; ls = SHIP(cc->vessels); for (n = 0; n < NNATION; n++) nat[n] = 0; foreachship(sp) { if (sp->file == NULL && (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) { puts("OUT OF MEMORY"); exit(1); } sp->file->index = sp - SHIP(0); sp->file->stern = nat[sp->nationality]++; sp->file->dir = sp->shipdir; sp->file->row = sp->shiprow; sp->file->col = sp->shipcol; } windspeed = cc->windspeed; winddir = cc->winddir; signal(SIGHUP, choke); signal(SIGINT, choke); hasdriver = sync_exists(game); if (sync_open() < 0) { perror("sail: syncfile"); exit(1); } if (hasdriver) { puts("Synchronizing with the other players..."); fflush(stdout); if (Sync() < 0) leave(LEAVE_SYNC); } for (;;) { foreachship(sp) if (sp->file->captain[0] == 0 && !sp->file->struck && sp->file->captured == 0) break; if (sp >= ls) { puts("All ships taken in that scenario."); foreachship(sp) free((char *)sp->file); sync_close(0); people = 0; goto reprint; } if (randomize) { player = sp - SHIP(0); } else { printf("%s\n\n", cc->name); foreachship(sp) printf(" %2d: %-10s %-15s (%-2d pts) %s\n", sp->file->index, countryname[sp->nationality], sp->shipname, sp->specs->pts, saywhat(sp, 1)); printf("\nWhich ship (0-%d)? ", cc->vessels-1); fflush(stdout); if (scanf("%d", &player) != 1 || player < 0 || player >= cc->vessels) { while (getchar() != '\n') ; puts("Say what?"); player = -1; } else while (getchar() != '\n') ; } if (player < 0) continue; if (Sync() < 0) leave(LEAVE_SYNC); fp = SHIP(player)->file; if (fp->captain[0] || fp->struck || fp->captured != 0) puts("That ship is taken."); else break; } ms = SHIP(player); mf = ms->file; mc = ms->specs; Write(W_BEGIN, ms, 0, 0, 0, 0); if (Sync() < 0) leave(LEAVE_SYNC); signal(SIGCHLD, child); if (!hasdriver) switch (fork()) { case 0: longjmp(restart, MODE_DRIVER); /*NOTREACHED*/ case -1: perror("fork"); leave(LEAVE_FORK); break; default: hasdriver++; } printf("Your ship is the %s, a %d gun %s (%s crew).\n", ms->shipname, mc->guns, classname[mc->class], qualname[mc->qual]); if ((nameptr = (char *) getenv("SAILNAME")) && *nameptr) strncpy(captain, nameptr, sizeof captain); else { printf("Your name, Captain? "); fflush(stdout); fgets(captain, sizeof captain, stdin); if (!*captain) strcpy(captain, "no name"); else captain[strlen(captain) - 1] = '\0'; } captain[sizeof captain - 1] = '\0'; Writestr(W_CAPTAIN, ms, captain); for (n = 0; n < 2; n++) { char buf[10]; printf("\nInitial broadside %s (grape, chain, round, double): ", n ? "right" : "left"); fflush(stdout); scanf("%s", buf); switch (*buf) { case 'g': load = L_GRAPE; break; case 'c': load = L_CHAIN; break; case 'r': load = L_ROUND; break; case 'd': load = L_DOUBLE; break; default: load = L_ROUND; } if (n) { mf->loadR = load; mf->readyR = R_LOADED|R_INITIAL; } else { mf->loadL = load; mf->readyL = R_LOADED|R_INITIAL; } } initscreen(); draw_board(); snprintf(message, sizeof message, "Captain %s assuming command", captain); Writestr(W_SIGNAL, ms, message); newturn(0); } bsd-games-2.17/sail/globals.c0000664000175000017500000005246707767741711014555 0ustar jsm28jsm28/* $NetBSD: globals.c,v 1.13 2003/08/07 09:37:42 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: globals.c,v 1.13 2003/08/07 09:37:42 agc Exp $"); #endif #endif /* not lint */ #include #include #include "extern.h" struct scenario scene[] = { /* * int winddir; * int windspeed; * int windchange; * int vessels; * char *name; * struct ship ship[NSHIP]; */ { 5, 3, 5, 2, "Ranger vs. Drake", { { "Ranger", specs+0, N_A, 7, 20, 4, 0 }, { "Drake", specs+1, N_B, 7, 31, 5, 0 } } }, { 1, 3, 6, 2, "The Battle of Flamborough Head", { { "Bonhomme Rich", specs+2, N_A, 13, 40, 2, 0 }, { "Serapis", specs+3, N_B, 2, 42, 2, 0 } } }, { 5, 5, 5, 10, "Arbuthnot and Des Touches", { { "America", specs+4, N_B, 7, 37, 4, 0 }, { "Befford", specs+5, N_B, 5, 35, 4, 0 }, { "Adamant", specs+6, N_B, 3, 33, 4, 0 }, { "London", specs+7, N_B, 1, 31, 4, 0 }, { "Royal Oak", specs+8, N_B, -1, 29, 4, 0 }, { "Neptune", specs+9, N_F, 6, 44, 4, 0 }, { "Duc Bougogne", specs+10, N_F, 8, 46, 4, 0 }, { "Conquerant", specs+48, N_F, 10, 48, 4, 0 }, { "Provence", specs+11, N_F, 12, 50, 4, 0 }, { "Romulus", specs+12, N_F, 20, 58, 4, 0 } } }, { 1, 3, 5, 10, "Suffren and Hughes", { { "Monmouth", specs+52, N_B, 9, 45, 2, 0 }, { "Hero", specs+5, N_B, 13, 49, 2, 0 }, { "Isis", specs+6, N_B, 12, 48, 2, 0 }, { "Superb", specs+50, N_B, 10, 46, 2, 0 }, { "Burford", specs+48, N_B, 11, 47, 2, 0 }, { "Flamband", specs+13, N_F, 7, 59, 4, 0 }, { "Annibal", specs+9, N_F, 4, 56, 4, 0 }, { "Severe", specs+11, N_F, 2, 54, 4, 0 }, { "Brilliant", specs+49, N_F, -1, 51, 4, 0 }, { "Sphinx", specs+51, N_F, -5, 47, 4, 0 } } }, { 1, 3, 4, 2, "Nymphe vs. Cleopatre", { { "Nymphe", specs+14, N_B, 13, 30, 2, 0 }, { "Cleopatre", specs+15, N_F, 3, 41, 2, 0 } } }, { 1, 3, 5, 2, "Mars vs. Hercule", { { "Mars", specs+16, N_B, 13, 30, 2, 0 }, { "Hercule", specs+17, N_F, 3, 41, 2, 0 } } }, { 5, 3, 5, 2, "Ambuscade vs. Baionnaise", { { "Ambuscade", specs+18, N_B, 13, 30, 2, 0 }, { "Baionnaise", specs+19, N_F, 3, 41, 2, 0 } } }, { 1, 5, 6, 2, "Constellation vs. Insurgent", { { "Constellation", specs+20, N_A, 9, 50, 8, 0 }, { "Insurgent", specs+22, N_F, 4, 24, 2, 0 } } }, { 1, 3, 5, 2, "Constellation vs. Vengeance", { { "Constellation", specs+20, N_A, 12, 40, 2, 0 }, { "Vengeance", specs+21, N_F, 1, 43, 2, 0 } } }, { 1, 3, 6, 10, "The Battle of Lissa", { { "Amphion", specs+23, N_B, 8, 50, 4, 0 }, { "Active", specs+24, N_B, 6, 48, 4, 0 }, { "Volage", specs+25, N_B, 4, 46, 4, 0 }, { "Cerberus", specs+26, N_B, 2, 44, 4, 0 }, { "Favorite", specs+27, N_F, 9, 34, 2, 0 }, { "Flore", specs+21, N_F, 13, 39, 2, 0 }, { "Danae", specs+64, N_F, 15, 37, 2, 0 }, { "Bellona", specs+28, N_F, 17, 35, 2, 0 }, { "Corona", specs+29, N_F, 12, 31, 2, 0 }, { "Carolina", specs+30, N_F, 15, 28, 2, 0 } } }, { 2, 5, 6, 2, "Constitution vs. Guerriere", { { "Constitution", specs+31, N_A, 7, 35, 1, 0 }, { "Guerriere", specs+32, N_B, 7, 47, 4, 0 } } }, { 1, 3, 5, 2, "United States vs. Macedonian", { { "United States", specs+33, N_A, 1, 52, 6, 0 }, { "Macedonian", specs+34, N_B, 14, 40, 1, 0 } } }, { 1, 3, 6, 2, "Constitution vs. Java", { { "Constitution", specs+31, N_A, 1, 40, 2, 0 }, { "Java", specs+35, N_B, 11, 40, 2, 0 } } }, { 1, 3, 5, 2, "Chesapeake vs. Shannon", { { "Chesapeake", specs+36, N_A, 13, 40, 2, 0 }, { "Shannon", specs+37, N_B, 1, 42, 2, 0 } } }, { 1, 1, 6, 5, "The Battle of Lake Erie", { { "Lawrence", specs+38, N_A, 4, 55, 8, 0 }, { "Niagara", specs+42, N_A, 7, 61, 8, 0 }, { "Lady Prevost", specs+39, N_B, 4, 25, 2, 0 }, { "Detroit", specs+40, N_B, 7, 22, 2, 0 }, { "Q. Charlotte", specs+41, N_B, 10, 19, 2, 0 } } }, { 1, 1, 5, 2, "Wasp vs. Reindeer", { { "Wasp", specs+42, N_A, 3, 41, 2, 0 }, { "Reindeer", specs+43, N_B, 10, 48, 2, 0 } } }, { 1, 2, 5, 3, "Constitution vs. Cyane and Levant", { { "Constitution", specs+31, N_A, 10, 45, 2, 0 }, { "Cyane", specs+44, N_B, 3, 37, 2, 0 }, { "Levant", specs+45, N_B, 5, 35, 2, 0 } } }, { 5, 5, 5, 3, "Pellew vs. Droits de L'Homme", { { "Indefatigable", specs+46, N_B, 12, 45, 6, 0 }, { "Amazon", specs+47, N_B, 9, 48, 6, 0 }, { "Droits L'Hom", specs+48, N_F, 3, 28, 5, 0 } } }, { 2, 2, 3, 10, "Algeciras", { { "Caesar", specs+49, N_B, 7, 70, 6, 0 }, { "Pompee", specs+50, N_B, 5, 72, 6, 0 }, { "Spencer", specs+5, N_B, 3, 74, 6, 0 }, { "Hannibal", specs+7, N_B, 1, 76, 6, 0 }, { "Real-Carlos", specs+53, N_S, 9, 20, 3, 0 }, { "San Fernando", specs+54, N_S, 11, 16, 3, 0 }, { "Argonauta", specs+55, N_S, 10, 14, 4, 0 }, { "San Augustine", specs+56, N_S, 6, 22, 4, 0 }, { "Indomptable", specs+51, N_F, 7, 23, 5, 0 }, { "Desaix", specs+52, N_F, 7, 27, 7, 0 } } }, { 5, 3, 6, 7, "Lake Champlain", { { "Saratoga", specs+60, N_A, 8, 10, 1, 0 }, { "Eagle", specs+61, N_A, 9, 13, 2, 0 }, { "Ticonderoga", specs+62, N_A, 12, 17, 3, 0 }, { "Preble", specs+63, N_A, 14, 20, 2, 0 }, { "Confiance", specs+57, N_B, 4, 70, 6, 0 }, { "Linnet", specs+58, N_B, 7, 68, 6, 0 }, { "Chubb", specs+59, N_B, 10, 65, 6, 0 } } }, { 5, 3, 6, 4, "Last Voyage of the USS President", { { "President", specs+67, N_A, 12, 42, 5, 0 }, { "Endymion", specs+64, N_B, 5, 42, 5, 0 }, { "Pomone", specs+65, N_B, 7, 82, 6, 0 }, { "Tenedos", specs+66, N_B, 7, -1, 4, 0 } } }, { 7, 5, 5, 2, "Hornblower and the Natividad", { { "Lydia", specs+68, N_B, 12, 40, 2, 0 }, { "Natividad", specs+69, N_S, 2, 40, 4, 0 } } }, { 1, 3, 6, 2, "Curse of the Flying Dutchman", { { "Piece of Cake", specs+19, N_S, 7, 40, 2, 0 }, { "Flying Dutchy", specs+71, N_F, 7, 41, 1, 0 } } }, { 1, 4, 1, 4, "The South Pacific", { { "USS Scurvy", specs+70, N_A, 7, 40, 1, 0 }, { "HMS Tahiti", specs+71, N_B, 12, 60, 1, 0 }, { "Australian", specs+18, N_S, 5, 20, 8, 0 }, { "Bikini Atoll", specs+63, N_F, 2, 60, 4, 0 } } }, { 7, 3, 6, 5, "Hornblower and the battle of Rosas bay", { { "Sutherland", specs+5, N_B, 13, 30, 2, 0 }, { "Turenne", specs+10, N_F, 9, 35, 6, 0 }, { "Nightmare", specs+9, N_F, 7, 37, 6, 0 }, { "Paris", specs+53, N_F, 3, 45, 4, 0 }, { "Napoleon", specs+56, N_F, 1, 40, 6, 0 } } }, { 6, 4, 7, 5, "Cape Horn", { { "Concord", specs+51, N_A, 3, 20, 4, 0 }, { "Berkeley", specs+7, N_A, 5, 50, 5, 0 }, { "Thames", specs+71, N_B, 10, 40, 1, 0 }, { "Madrid", specs+53, N_S, 13, 60, 8, 0 }, { "Musket", specs+10, N_F, 10, 60, 7, 0 } } }, { 8, 3, 7, 3, "New Orleans", { { "Alligator", specs+71, N_A, 13, 5, 1, 0 }, { "Firefly", specs+50, N_B, 10, 20, 8, 0 }, { "Cypress", specs+46, N_B, 5, 10, 6, 0 } } }, { 5, 3, 7, 3, "Botany Bay", { { "Shark", specs+11, N_B, 6, 15, 4, 0 }, { "Coral Snake", specs+31, N_F, 3, 30, 6, 0 }, { "Sea Lion", specs+33, N_F, 13, 50, 8, 0 } } }, { 4, 3, 6, 4, "Voyage to the Bottom of the Sea", { { "Seaview", specs+71, N_A, 6, 3, 3, 0 }, { "Flying Sub", specs+64, N_A, 8, 3, 3, 0 }, { "Mermaid", specs+70, N_B, 2, 5, 5, 0 }, { "Giant Squid", specs+53, N_S, 10, 30, 8, 0 } } }, { 7, 3, 6, 3, "Frigate Action", { { "Killdeer", specs+21, N_A, 7, 20, 8, 0 }, { "Sandpiper", specs+27, N_B, 5, 40, 8, 0 }, { "Curlew", specs+34, N_S, 10, 60, 8, 0 } } }, { 7, 2, 5, 6, "The Battle of Midway", { { "Enterprise", specs+49, N_A, 10, 70, 8, 0 }, { "Yorktown", specs+51, N_A, 3, 70, 7, 0 }, { "Hornet", specs+52, N_A, 6, 70, 7, 0 }, { "Akagi", specs+53, N_J, 6, 10, 4, 0 }, { "Kaga", specs+54, N_J, 4, 12, 4, 0 }, { "Soryu", specs+55, N_J, 2, 14, 4, 0 } } }, { 1, 3, 4, 8, "Star Trek", { { "Enterprise", specs+76, N_D,-10, 60, 7, 0 }, { "Yorktown", specs+77, N_D, 0, 70, 7, 0 }, { "Reliant", specs+78, N_D, 10, 70, 7, 0 }, { "Galileo", specs+79, N_D, 20, 60, 7, 0 }, { "Kobayashi Maru", specs+80, N_K, 0,120, 7, 0 }, { "Klingon II", specs+81, N_K, 10,120, 7, 0 }, { "Red Orion", specs+82, N_O, 0, 0, 3, 0 }, { "Blue Orion", specs+83, N_O, 10, 0, 3, 0 } } } }; int nscene = sizeof scene / sizeof (struct scenario); struct shipspecs specs[] = { /* bs fs ta guns hull crew1 crew3 gunR carR rig2 rig4 pts */ /* class qual crew2 gunL carL rig1 rig3 */ /*00*/{ 4, 7, 3, 19, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 4, 4, 4, 4, 7 }, /*01*/{ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 0, 0, 4, 4, 3, 3, 3, 3, 6 }, /*02*/{ 3, 5, 2, 42, 4, 7, 4, 2, 2, 2, 2, 2, 0, 0, 5, 5, 5, -1, 11 }, /*03*/{ 4, 6, 3, 44, 3, 7, 4, 2, 2, 2, 3, 3, 0, 0, 5, 5, 5, 5, 12 }, /*04*/{ 3, 5, 2, 64, 2, 17, 4, 8, 6, 6, 12, 12, 2, 2, 7, 7, 7, -1, 20 }, /*05*/{ 3, 5, 2, 74, 2, 20, 4, 8, 8, 8, 16, 16, 2, 2, 7, 7, 7, -1, 26 }, /*06*/{ 3, 5, 2, 50, 2, 12, 4, 6, 4, 4, 8, 8, 2, 2, 6, 6, 6, -1, 17 }, /*07*/{ 3, 5, 1, 98, 1, 23, 4, 10, 10, 10, 18, 18, 2, 2, 8, 8, 8, -1, 28 }, /*08*/{ 3, 5, 2, 74, 2, 20, 4, 8, 8, 8, 16, 16, 2, 2, 7, 7, 7, -1, 26 }, /*09*/{ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 0, 0, 7, 7, 7, -1, 24 }, /*10*/{ 3, 5, 1, 80, 1, 23, 3, 12, 12, 10, 22, 22, 0, 0, 7, 7, 7, -1, 27 }, /*11*/{ 3, 5, 2, 64, 2, 18, 3, 8, 8, 6, 12, 12, 0, 0, 7, 7, 7, -1, 18 }, /*12*/{ 3, 5, 2, 44, 2, 11, 3, 4, 4, 4, 6, 6, 2, 2, 5, 5, 5, -1, 10 }, /*13*/{ 3, 5, 2, 50, 2, 14, 3, 6, 6, 4, 8, 8, 0, 0, 6, 6, 6, -1, 14 }, /*14*/{ 4, 6, 3, 36, 3, 11, 4, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 11 }, /*15*/{ 4, 6, 3, 36, 3, 11, 3, 4, 4, 4, 4, 4, 2, 2, 5, 5, 5, 5, 10 }, /*16*/{ 3, 5, 2, 74, 2, 21, 4, 10, 8, 8, 18, 18, 2, 2, 7, 7, 7, -1, 26 }, /*17*/{ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 2, 2, 7, 7, 7, -1, 23 }, /*18*/{ 4, 6, 3, 32, 3, 8, 3, 4, 2, 2, 4, 4, 2, 2, 5, 5, 5, 5, 9 }, /*19*/{ 4, 6, 3, 24, 4, 6, 3, 4, 4, 4, 2, 2, 0, 0, 4, 4, 4, 4, 9 }, /*20*/{ 4, 7, 3, 38, 4, 14, 5, 6, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5, 17 }, /*21*/{ 4, 6, 3, 40, 3, 15, 3, 8, 6, 6, 6, 6, 4, 4, 5, 5, 5, 5, 15 }, /*22*/{ 4, 7, 3, 36, 4, 11, 3, 6, 6, 4, 4, 4, 2, 2, 5, 5, 5, 5, 11 }, /*23*/{ 4, 6, 3, 32, 3, 11, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13 }, /*24*/{ 4, 6, 3, 38, 3, 14, 5, 4, 4, 4, 6, 6, 4, 4, 5, 5, 5, 5, 18 }, /*25*/{ 4, 6, 3, 22, 3, 6, 5, 2, 2, 2, 0, 0, 8, 8, 4, 4, 4, 4, 11 }, /*26*/{ 4, 6, 3, 32, 3, 11, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13 }, /*27*/{ 4, 6, 3, 40, 3, 14, 3, 6, 6, 4, 6, 6, 4, 4, 5, 5, 5, 5, 15 }, /*28*/{ 4, 6, 3, 32, 3, 11, 2, 4, 4, 4, 4, 4, 0, 0, 5, 5, 5, 5, 9 }, /*29*/{ 4, 6, 3, 40, 3, 14, 2, 6, 6, 4, 6, 6, 4, 4, 5, 5, 5, 5, 12 }, /*30*/{ 4, 6, 3, 32, 3, 8, 2, 4, 4, 1, 2, 2, 0, 0, 4, 4, 4, 4, 7 }, /*31*/{ 4, 7, 3, 44, 4, 18, 5, 6, 6, 6, 8, 8, 6, 6, 6, 6, 6, 6, 24 }, /*32*/{ 4, 6, 3, 38, 3, 14, 4, 4, 4, 2, 6, 6, 4, 4, 5, 5, 5, 5, 15 }, /*33*/{ 4, 5, 3, 44, 3, 18, 5, 8, 6, 6, 8, 8, 8, 8, 6, 6, 6, 6, 24 }, /*34*/{ 4, 6, 3, 38, 3, 14, 4, 4, 4, 4, 6, 6, 4, 4, 5, 5, 5, 5, 16 }, /*35*/{ 4, 7, 3, 38, 4, 14, 4, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 19 }, /*36*/{ 4, 6, 3, 38, 3, 14, 3, 6, 6, 4, 6, 6, 6, 6, 5, 5, 5, 5, 14 }, /*37*/{ 4, 6, 3, 38, 3, 14, 5, 6, 4, 4, 6, 6, 6, 6, 5, 5, 5, 5, 17 }, /*38*/{ 4, 7, 3, 20, 5, 6, 4, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9 }, /*39*/{ 4, 7, 3, 13, 6, 3, 4, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 5 }, /*40*/{ 4, 7, 3, 19, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 4, 4, 4, 4, 7 }, /*41*/{ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 3, 3, 3, 3, 6 }, /*42*/{ 4, 7, 3, 20, 5, 6, 5, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 12 }, /*43*/{ 4, 7, 3, 18, 5, 5, 5, 2, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9 }, /*44*/{ 4, 7, 3, 24, 5, 6, 4, 4, 2, 2, 0, 0,10,10, 4, 4, 4, 4, 11 }, /*45*/{ 4, 7, 3, 20, 5, 6, 4, 2, 2, 2, 0, 0, 8, 8, 4, 4, 4, 4, 10 }, /*46*/{ 4, 6, 3, 44, 3, 11, 5, 4, 4, 4, 4, 4, 2, 2, 5, 5, 5, 5, 14 }, /*47*/{ 4, 6, 3, 36, 3, 12, 4, 4, 4, 4, 6, 6, 2, 2, 5, 5, 5, 5, 14 }, /*48*/{ 3, 5, 2, 74, 2, 21, 3, 10, 8, 8, 20, 20, 2, 2, 4, 4, 7, -1, 24 }, /*49*/{ 3, 5, 2, 80, 2, 24, 4, 10, 8, 8, 20, 20, 2, 2, 8, 8, 8, -1, 31 }, /*50*/{ 3, 5, 2, 74, 2, 21, 4, 8, 8, 6, 16, 16, 4, 4, 7, 7, 7, -1, 27 }, /*51*/{ 3, 5, 2, 80, 2, 24, 3, 12, 12, 10, 22, 22, 2, 2, 7, 7, 7, -1, 27 }, /*52*/{ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 2, 2, 7, 7, 7, -1, 24 }, /*53*/{ 3, 5, 1, 112, 1, 27, 2, 12, 12, 12, 24, 24, 0, 0, 9, 9, 9, -1, 27 }, /*54*/{ 3, 5, 1, 96, 1, 24, 2, 12, 12, 10, 20, 20, 0, 0, 8, 8, 8, -1, 24 }, /*55*/{ 3, 5, 2, 80, 2, 23, 2, 10, 10, 8, 20, 20, 0, 0, 7, 7, 7, -1, 23 }, /*56*/{ 3, 5, 2, 74, 2, 21, 2, 10, 8, 8, 16, 16, 4, 4, 7, 7, 7, -1, 20 }, /*57*/{ 4, 6, 3, 37, 3, 12, 4, 4, 4, 2, 6, 6, 4, 4, 5, 5, 5, 5, 14 }, /*58*/{ 4, 7, 3, 16, 5, 5, 5, 2, 2, 2, 0, 0, 4, 4, 4, 4, 4, 4, 10 }, /*59*/{ 4, 7, 3, 11, 6, 3, 4, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 5 }, /*60*/{ 4, 7, 3, 26, 5, 6, 4, 4, 2, 2, 2, 2, 6, 6, 4, 4, 4, 4, 12 }, /*61*/{ 4, 7, 3, 20, 5, 6, 4, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 11 }, /*62*/{ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9 }, /*63*/{ 4, 7, 3, 7, 6, 3, 4, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 4 }, /*64*/{ 4, 6, 3, 40, 3, 15, 4, 4, 4, 4, 8, 8, 6, 6, 5, 5, 5, 5, 17 }, /*65*/{ 4, 6, 3, 44, 3, 15, 4, 8, 8, 6, 10, 10, 2, 2, 6, 6, 6, 6, 20 }, /*66*/{ 4, 6, 3, 38, 3, 14, 4, 4, 4, 4, 6, 6, 6, 6, 5, 5, 5, 5, 15 }, /*67*/{ 4, 5, 3, 44, 3, 18, 5, 8, 6, 6, 8, 8, 8, 8, 6, 6, 6, 6, 24 }, /*68*/{ 4, 6, 3, 36, 3, 9, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13 }, /*69*/{ 3, 5, 2, 50, 2, 14, 2, 6, 6, 6, 8, 8, 0, 0, 6, 6, 6, -1, 14 }, /*70*/{ 3, 5, 1, 136, 1, 30, 1, 8, 14, 14, 28, 28, 0, 0, 9, 9, 9, -1, 27 }, /*71*/{ 3, 5, 1, 120, 1, 27, 5, 16, 14, 14, 28, 28, 2, 2, 9, 9, 9, -1, 43 }, /*72*/{ 3, 5, 1, 120, 2, 21, 5, 15, 17, 15, 25, 25, 7, 7, 9, 9, 9, -1, 36 }, /*73*/{ 3, 5, 1, 90, 3, 18, 4, 13, 15, 13, 20, 20, 6, 6, 5, 5, 5, 5, 28 }, /*74*/{ 4, 7, 3, 6, 6, 3, 4, 2, 2, 2, 20, 20, 6, 6, 2, 2, 3, 3, 5 }, /*75*/{ 3, 5, 1, 110, 2, 20, 4, 14, 15, 11, 26, 26, 8, 8, 7, 8, 9, -1, 34 }, /*76*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, /*77*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, /*78*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, /*79*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, /*80*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, /*81*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, /*82*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, /*83*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 } /* bs fs ta guns hull crew1 crew3 gunR carR rig2 rig4 pts */ /* class qual crew2 gunL carL rig1 rig3 */ }; const struct windeffects WET[7][6] = { { {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9} }, { {3,2,2,0}, {3,2,1,0}, {3,2,1,0}, {3,2,1,0}, {2,1,0,0}, {2,1,0,0} }, { {1,1,1,0}, {1,1,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0} }, { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} }, { {0,0,0,0}, {1,0,0,0}, {1,1,0,0}, {1,1,0,0}, {2,2,1,0}, {2,2,1,0} }, { {1,0,0,0}, {1,1,0,0}, {1,1,1,0}, {1,1,1,0}, {3,2,2,0}, {3,2,2,0} }, { {2,1,1,0}, {3,2,1,0}, {3,2,1,0}, {3,2,1,0}, {3,3,2,0}, {3,3,2,0} } }; const struct Tables RigTable[11][6] = { { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,1}, {0,0,1,0} }, { {0,0,0,0}, {0,0,0,0}, {0,0,0,1}, {0,0,1,0}, {1,0,0,1}, {0,1,1,1} }, { {0,0,0,0}, {0,0,0,1}, {0,0,1,1}, {0,1,0,1}, {0,1,0,1}, {1,0,1,2} }, { {0,0,0,0}, {0,0,1,1}, {0,1,0,1}, {0,0,0,2}, {0,1,0,2}, {1,0,1,2} }, { {0,1,0,1}, {1,0,0,1}, {0,1,1,2}, {0,1,0,2}, {0,0,1,3}, {1,0,1,4} }, { {0,0,1,1}, {0,1,0,2}, {1,0,0,3}, {0,1,1,3}, {1,0,0,4}, {1,1,1,4} }, { {0,0,1,2}, {0,1,1,2}, {1,1,0,3}, {0,1,0,4}, {1,0,0,4}, {1,0,1,5} }, { {0,0,1,2}, {0,1,0,3}, {1,1,0,3}, {1,0,2,4}, {0,2,1,5}, {2,1,0,5} }, { {0,2,1,3}, {1,0,0,3}, {2,1,0,4}, {0,1,1,4}, {0,1,0,5}, {1,0,2,6} }, { {1,1,0,4}, {1,0,1,4}, {2,0,0,5}, {0,2,1,5}, {0,1,2,6}, {0,2,0,7} }, { {1,0,1,5}, {0,2,0,6}, {1,2,0,6}, {1,1,1,6}, {2,0,2,6}, {1,1,2,7} } }; const struct Tables HullTable[11][6] = { { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,0,0,0}, {0,1,0,0} }, { {0,0,0,0}, {0,0,0,0}, {0,1,0,0}, {1,1,0,0}, {1,0,1,0}, {1,0,1,1} }, { {0,1,0,0}, {1,0,0,0}, {1,1,0,0}, {1,0,1,0}, {1,0,1,1}, {2,1,0,0} }, { {0,1,1,0}, {1,0,0,0}, {1,1,1,0}, {2,0,0,1}, {2,0,1,0}, {2,2,0,0} }, { {0,1,1,0}, {1,0,0,1}, {2,1,0,1}, {2,2,1,0}, {3,0,1,0}, {3,1,0,0} }, { {1,1,1,0}, {2,0,2,1}, {2,1,1,0}, {2,2,0,0}, {3,1,0,1}, {3,1,1,0} }, { {1,2,2,0}, {2,0,2,1}, {2,1,0,1}, {2,2,0,0}, {3,1,1,0}, {4,2,1,0} }, { {2,1,1,0}, {2,0,1,1}, {3,2,2,0}, {3,2,0,0}, {4,2,1,0}, {4,2,1,1} }, { {2,1,2,0}, {3,1,1,1}, {3,2,2,0}, {4,2,1,0}, {4,1,0,2}, {4,2,2,0} }, { {2,3,1,0}, {3,2,2,0}, {3,2,2,1}, {4,2,2,0}, {4,1,0,3}, {5,1,2,0} }, { {2,2,4,0}, {3,3,1,1}, {4,2,1,1}, {5,1,0,2}, {5,1,2,1}, {6,2,2,0} }, }; const char AMMO[9][4] = { { -1, 1, 0, 1 }, { -1, 1, 0, 1 }, { -1, 1, 0, 1 }, { -2, 1, 0, 2 }, { -2, 2, 0, 2 }, { -2, 2, 0, 2 }, { -3, 2, 0, 2 }, { -3, 2, 0, 3 }, { -3, 2, 0, 3 } }; const char HDT[9][10] = { { 1, 0,-1,-2,-3,-3,-4,-4,-4,-4 }, { 1, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, { 2, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, { 2, 2, 1, 0,-1,-1,-2,-2,-2,-2 }, { 3, 2, 1, 0,-1,-1,-2,-2,-2,-2 }, { 3, 3, 2, 1, 0, 0,-1,-1,-1,-1 }, { 4, 3, 2, 1, 0, 0,-1,-1,-1,-1 }, { 4, 4, 3, 2, 1, 1, 0, 0, 0, 0 }, { 5, 4, 3, 2, 1, 1, 0, 0, 0, 0 } }; const char HDTrake[9][10] = { { 2, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, { 2, 2, 1, 0,-1,-1,-2,-2,-2,-2 }, { 3, 2, 1, 0,-1,-1,-2,-2,-2,-2 }, { 4, 3, 2, 1, 0, 0,-1,-1,-1,-1 }, { 5, 4, 3, 2, 1, 1, 0, 0, 0, 0 }, { 6, 5, 4, 3, 2, 2, 1, 1, 1, 1 }, { 7, 6, 5, 4, 3, 3, 2, 2, 2, 2 }, { 8, 7, 6, 5, 4, 4, 3, 3, 3, 3 }, { 9, 8, 7, 6, 5, 5, 4, 4, 4, 4 } }; const char QUAL[9][5] = { { -1, 0, 0, 1, 1 }, { -1, 0, 0, 1, 1 }, { -1, 0, 0, 1, 2 }, { -1, 0, 0, 1, 2 }, { -1, 0, 0, 2, 2 }, { -1,-1, 0, 2, 2 }, { -2,-1, 0, 2, 2 }, { -2,-1, 0, 2, 2 }, { -2,-1, 0, 2, 3 } }; const char MT[9][3] = { { 1, 0, 0 }, { 1, 1, 0 }, { 2, 1, 0 }, { 2, 1, 1 }, { 2, 2, 1 }, { 3, 2, 1 }, { 3, 2, 2 }, { 4, 3, 2 }, { 4, 4, 2 } }; const char rangeofshot[] = { 0, 1, /* grape */ 3, /* chain */ 10, /* round */ 1 /* double */ }; const char *const countryname[] = { "American", "British", "Spanish", "French", "Japanese", "Federation", "Klingon", "Orion" }; const char *const classname[] = { "Drift wood", "Ship of the Line", "Ship of the Line", "Frigate", "Corvette", "Sloop", "Brig" }; const char *const directionname[] = { "dead ahead", "off the starboard bow", "off the starboard beam", "off the starboard quarter", "dead astern", "off the port quarter", "off the port beam", "off the port bow", "dead ahead" }; const char *const qualname[] = { "dead", "mutinous", "green", "mundane", "crack", "elite" }; const char loadname[] = { '-', 'G', 'C', 'R', 'D', 'E' }; const char dr[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 }; const char dc[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 }; int mode; jmp_buf restart; int randomize; /* -x, give first available ship */ int longfmt; /* -l, print score in long format */ int nobells; /* -b, don't ring bell before Signal */ gid_t gid; gid_t egid; struct scenario *cc; /* the current scenario */ struct ship *ls; /* &cc->ship[cc->vessels] */ int winddir; int windspeed; int turn; int game; int alive; int people; int hasdriver; bsd-games-2.17/sail/main.c0000664000175000017500000000643610005231365014023 0ustar jsm28jsm28/* $NetBSD: main.c,v 1.21 2003/08/07 09:37:43 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: main.c,v 1.21 2003/08/07 09:37:43 agc Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include #include "extern.h" #include "restart.h" int main(int argc, char **argv) { char *p; int a,i; int fd; gid = getgid(); egid = getegid(); setegid(gid); fd = open("/dev/null", O_RDONLY); if (fd < 3) exit(1); close(fd); srandom((u_long)time(NULL)); if ((p = strrchr(*argv, '/')) != NULL) p++; else p = *argv; if (strcmp(p, "driver") == 0 || strcmp(p, "saildriver") == 0) mode = MODE_DRIVER; else if (strcmp(p, "sail.log") == 0) mode = MODE_LOGGER; else mode = MODE_PLAYER; while ((a = getopt(argc, argv, "dsxlb")) != -1) switch (a) { case 'd': mode = MODE_DRIVER; break; case 's': mode = MODE_LOGGER; break; case 'x': randomize++; break; case 'l': longfmt++; break; case 'b': nobells++; break; default: fprintf(stderr, "SAIL: Unknown flag %s.\n", p); exit(1); } argc -= optind; argv += optind; if (*argv) game = atoi(*argv); else game = -1; if ((i = setjmp(restart)) != 0) mode = i; switch (mode) { case MODE_PLAYER: return pl_main(); case MODE_DRIVER: return dr_main(); case MODE_LOGGER: return lo_main(); default: fprintf(stderr, "SAIL: Unknown mode %d.\n", mode); abort(); } /*NOTREACHED*/ } bsd-games-2.17/sail/version.c0000664000175000017500000000361707767741711014610 0ustar jsm28jsm28/* $NetBSD: version.c,v 1.5 2003/08/07 09:37:45 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: version.c,v 1.5 2003/08/07 09:37:45 agc Exp $"); #endif #endif /* not lint */ char version[] = "Wooden Ships and Iron Men, Version 8.1 (93/05/31)"; bsd-games-2.17/sail/restart.h0000664000175000017500000000373307240362720014574 0ustar jsm28jsm28/* $NetBSD: restart.h,v 1.2 2001/01/04 05:06:15 jwise Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ extern jmp_buf restart; bsd-games-2.17/sail/Makefrag0000664000175000017500000000340506773402557014410 0ustar jsm28jsm28# Makefrag - makefile fragment for sail # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. sail_DIRS := $(GAMESDIR) $(MAN6DIR) sail_all: sail/sail sail/sail.6 sail_install: sail_all $(INSTALL_SCORE_GAME) sail/sail $(INSTALL_PREFIX)$(GAMESDIR)/sail $(HIDE_GAME) sail $(INSTALL_SCORE_FILE) $(SAIL_SCOREFILE) $(INSTALL_SAIL_DIR) $(INSTALL_PREFIX)$(SAIL_DIR) $(INSTALL_MANUAL) sail/sail.6 bsd-games-2.17/sail/misc.c0000664000175000017500000001411410155330535014027 0ustar jsm28jsm28/* $NetBSD: misc.c,v 1.15 2004/11/05 21:30:32 dsl Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: misc.c,v 1.15 2004/11/05 21:30:32 dsl Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include "extern.h" #include "pathnames.h" #define distance(x,y) (abs(x) >= abs(y) ? abs(x) + abs(y)/2 : abs(y) + abs(x)/2) static int angle(int, int); /* XXX */ int range(struct ship *from, struct ship *to) { int bow1r, bow1c, bow2r, bow2c; int stern1r, stern1c, stern2c, stern2r; int bb, bs, sb, ss, result; if (!to->file->dir) return -1; stern1r = bow1r = from->file->row; stern1c = bow1c = from->file->col; stern2r = bow2r = to->file->row; stern2c = bow2c = to->file->col; result = bb = distance(bow2r - bow1r, bow2c - bow1c); if (bb < 5) { stern2r += dr[to->file->dir]; stern2c += dc[to->file->dir]; stern1r += dr[from->file->dir]; stern1c += dc[from->file->dir]; bs = distance((bow2r - stern1r), (bow2c - stern1c)); sb = distance((bow1r - stern2r), (bow1c - stern2c)); ss = distance((stern2r - stern1r) ,(stern2c - stern1c)); result = min(bb, min(bs, min(sb, ss))); } return result; } struct ship * closestenemy(struct ship *from, int side, int anyship) { struct ship *sp; char a; int olddist = 30000, dist; struct ship *closest = 0; a = capship(from)->nationality; foreachship(sp) { if (sp == from) continue; if (sp->file->dir == 0) continue; if (a == capship(sp)->nationality && !anyship) continue; if (side && gunsbear(from, sp) != side) continue; dist = range(from, sp); if (dist < olddist) { closest = sp; olddist = dist; } } return closest; } static int angle(int dr, int dc) { int i; if (dc >= 0 && dr > 0) i = 0; else if (dr <= 0 && dc > 0) i = 2; else if (dc <= 0 && dr < 0) i = 4; else i = 6; dr = abs(dr); dc = abs(dc); if ((i == 0 || i == 4) && dc * 2.4 > dr) { i++; if (dc > dr * 2.4) i++; } else if ((i == 2 || i == 6) && dr * 2.4 > dc) { i++; if (dr > dc * 2.4) i++; } return i % 8 + 1; } /* checks for target bow or stern */ int gunsbear(struct ship *from, struct ship *to) { int Dr, Dc, i; int ang; Dr = from->file->row - to->file->row; Dc = to->file->col - from->file->col; for (i = 2; i; i--) { if ((ang = angle(Dr, Dc) - from->file->dir + 1) < 1) ang += 8; if (ang >= 2 && ang <= 4) return 'r'; if (ang >= 6 && ang <= 7) return 'l'; Dr += dr[to->file->dir]; Dc += dc[to->file->dir]; } return 0; } /* returns true if fromship is shooting at onship's starboard side */ int portside(struct ship *from, struct ship *on, int quick) { int ang; int Dr, Dc; Dr = from->file->row - on->file->row; Dc = on->file->col - from->file->col; if (quick == -1) { Dr += dr[on->file->dir]; Dc += dc[on->file->dir]; } ang = angle(Dr, Dc); if (quick != 0) return ang; ang = (ang + 4 - on->file->dir - 1) % 8 + 1; return ang < 5; } int colours(struct ship *sp) { char flag = '\0'; if (sp->file->struck) flag = '!'; if (sp->file->explode) flag = '#'; if (sp->file->sink) flag = '~'; if (sp->file->struck) return flag; flag = *countryname[capship(sp)->nationality]; return sp->file->FS ? flag : tolower((unsigned char)flag); } void logger(struct ship *s) { FILE *fp; int persons; int n; struct logs log[NLOG]; float net; struct logs *lp; setegid(egid); if ((fp = fopen(_PATH_LOGFILE, "r+")) == NULL) { setegid(gid); return; } setegid(gid); #ifdef LOCK_EX if (flock(fileno(fp), LOCK_EX) < 0) return; #endif net = (float)s->file->points / s->specs->pts; persons = getw(fp); n = fread((char *)log, sizeof(struct logs), NLOG, fp); for (lp = &log[n]; lp < &log[NLOG]; lp++) lp->l_name[0] = lp->l_uid = lp->l_shipnum = lp->l_gamenum = lp->l_netpoints = 0; rewind(fp); if (persons < 0) putw(1, fp); else putw(persons + 1, fp); for (lp = log; lp < &log[NLOG]; lp++) if (net > (float)lp->l_netpoints / scene[lp->l_gamenum].ship[lp->l_shipnum].specs->pts) { fwrite((char *)log, sizeof (struct logs), lp - log, fp); strcpy(log[NLOG-1].l_name, s->file->captain); log[NLOG-1].l_uid = getuid(); log[NLOG-1].l_shipnum = s->file->index; log[NLOG-1].l_gamenum = game; log[NLOG-1].l_netpoints = s->file->points; fwrite((char *)&log[NLOG-1], sizeof (struct logs), 1, fp); fwrite((char *)lp, sizeof (struct logs), &log[NLOG-1] - lp, fp); break; } #ifdef LOCK_EX flock(fileno(fp), LOCK_UN); #endif fclose(fp); } bsd-games-2.17/pom/0000775000175000017500000000000010205246607012574 5ustar jsm28jsm28bsd-games-2.17/pom/Makefrag0000664000175000017500000000323506773402557014254 0ustar jsm28jsm28# Makefrag - makefile fragment for pom # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. pom_DIRS := $(GAMESDIR) $(MAN6DIR) pom_all: pom/pom pom/pom.6 pom_install: pom_all $(INSTALL_BINARY) pom/pom $(INSTALL_PREFIX)$(GAMESDIR)/pom $(HIDE_GAME) pom $(INSTALL_MANUAL) pom/pom.6 bsd-games-2.17/pom/pom.60000664000175000017500000000511107767741711013473 0ustar jsm28jsm28.\" $NetBSD: pom.6,v 1.12 2003/08/07 09:37:32 agc Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)pom.6 8.1 (Berkeley) 5/31/93 .\" .Dd January 9, 1999 .Dt POM 6 .Os .Sh NAME .Nm pom .Nd display the phase of the moon .Sh SYNOPSIS .Nm .Op [[[[[cc]yy]mm]dd]HH] .Sh DESCRIPTION The .Nm utility displays the current phase of the moon. Useful for selecting software completion target dates and predicting managerial behavior. .Pp .Bl -tag -width [[[[[cc]yy]mm]dd]HH] .It Ar [[[[[cc]yy]mm]dd]HH] Display the phase of the moon for a given time. The format is similar to the canonical representation used by .Xr date 1 . .El .Sh SEE ALSO .Xr date 1 .Sh AUTHOR .Nm was written by .An Keith E. Brandt . .Sh BUGS Times must be within range of the .Ux epoch. .Pp This program does not allow for the difference between the TDT and UTC timescales (about one minute at the time of writing). .Sh ACKNOWLEDGEMENTS This program is based on algorithms from .%B Practical Astronomy with Your Calculator, Third Edition by Peter Duffett-Smith .Aq pjds@mrao.cam.ac.uk . bsd-games-2.17/pom/pom.c0000664000175000017500000001717110005547567013551 0ustar jsm28jsm28/* $NetBSD: pom.c,v 1.14 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software posted to USENET. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)pom.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: pom.c,v 1.14 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ /* * Phase of the Moon. Calculates the current phase of the moon. * Based on routines from `Practical Astronomy with Your Calculator', * by Duffett-Smith. Comments give the section from the book that * particular piece of code was adapted from. * * -- Keith E. Brandt VIII 1984 * * Updated to the Third Edition of Duffett-Smith's book, Paul Janzen, IX 1998 * */ #include #include #include #include #include #include #include #include #ifndef PI #define PI 3.14159265358979323846 #endif /* * The EPOCH in the third edition of the book is 1990 Jan 0.0 TDT. * In this program, we do not bother to correct for the differences * between UTC (as shown by the UNIX clock) and TDT. (TDT = TAI + 32.184s; * TAI-UTC = 32s in Jan 1999.) */ #define EPOCH_MINUS_1970 (20 * 365 + 5 - 1) /* 20 years, 5 leaps, back 1 day to Jan 0 */ #define EPSILONg 279.403303 /* solar ecliptic long at EPOCH */ #define RHOg 282.768422 /* solar ecliptic long of perigee at EPOCH */ #define ECCEN 0.016713 /* solar orbit eccentricity */ #define lzero 318.351648 /* lunar mean long at EPOCH */ #define Pzero 36.340410 /* lunar mean long of perigee at EPOCH */ #define Nzero 318.510107 /* lunar mean long of node at EPOCH */ void adj360(double *); double dtor(double); int main(int, char *[]); double potm(double); time_t parsetime(char *); void badformat(void) __attribute__((__noreturn__)); int main(argc, argv) int argc; char *argv[]; { time_t tmpt, now; double days, today, tomorrow; char buf[1024]; /* Revoke setgid privileges */ setregid(getgid(), getgid()); if (time(&now) == (time_t)-1) err(1, "time"); if (argc > 1) { tmpt = parsetime(argv[1]); strftime(buf, sizeof(buf), "%a %Y %b %e %H:%M:%S (%Z)", localtime(&tmpt)); printf("%s: ", buf); } else { tmpt = now; } days = (tmpt - EPOCH_MINUS_1970 * 86400) / 86400.0; today = potm(days) + .5; if (tmpt < now) (void)printf("The Moon was "); else if (tmpt == now) (void)printf("The Moon is "); else (void)printf("The Moon will be "); if ((int)today == 100) (void)printf("Full\n"); else if (!(int)today) (void)printf("New\n"); else { tomorrow = potm(days + 1); if ((int)today == 50) (void)printf("%s\n", tomorrow > today ? "at the First Quarter" : "at the Last Quarter"); /* today is 0.5 too big, but it doesn't matter here * since the phase is changing fast enough */ else { today -= 0.5; /* Now it might matter */ (void)printf("%s ", tomorrow > today ? "Waxing" : "Waning"); if (today > 50) (void)printf("Gibbous (%1.0f%% of Full)\n", today); else if (today < 50) (void)printf("Crescent (%1.0f%% of Full)\n", today); } } exit(0); } /* * potm -- * return phase of the moon */ double potm(days) double days; { double N, Msol, Ec, LambdaSol, l, Mm, Ev, Ac, A3, Mmprime; double A4, lprime, V, ldprime, D, Nm; N = 360 * days / 365.242191; /* sec 46 #3 */ adj360(&N); Msol = N + EPSILONg - RHOg; /* sec 46 #4 */ adj360(&Msol); Ec = 360 / PI * ECCEN * sin(dtor(Msol)); /* sec 46 #5 */ LambdaSol = N + Ec + EPSILONg; /* sec 46 #6 */ adj360(&LambdaSol); l = 13.1763966 * days + lzero; /* sec 65 #4 */ adj360(&l); Mm = l - (0.1114041 * days) - Pzero; /* sec 65 #5 */ adj360(&Mm); Nm = Nzero - (0.0529539 * days); /* sec 65 #6 */ adj360(&Nm); Ev = 1.2739 * sin(dtor(2*(l - LambdaSol) - Mm)); /* sec 65 #7 */ Ac = 0.1858 * sin(dtor(Msol)); /* sec 65 #8 */ A3 = 0.37 * sin(dtor(Msol)); Mmprime = Mm + Ev - Ac - A3; /* sec 65 #9 */ Ec = 6.2886 * sin(dtor(Mmprime)); /* sec 65 #10 */ A4 = 0.214 * sin(dtor(2 * Mmprime)); /* sec 65 #11 */ lprime = l + Ev + Ec - Ac + A4; /* sec 65 #12 */ V = 0.6583 * sin(dtor(2 * (lprime - LambdaSol))); /* sec 65 #13 */ ldprime = lprime + V; /* sec 65 #14 */ D = ldprime - LambdaSol; /* sec 67 #2 */ return(50.0 * (1 - cos(dtor(D)))); /* sec 67 #3 */ } /* * dtor -- * convert degrees to radians */ double dtor(deg) double deg; { return(deg * PI / 180); } /* * adj360 -- * adjust value so 0 <= deg <= 360 */ void adj360(deg) double *deg; { for (;;) if (*deg < 0) *deg += 360; else if (*deg > 360) *deg -= 360; else break; } #define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2; time_t parsetime(p) char *p; { struct tm *lt; int bigyear; int yearset = 0; time_t tval; unsigned char *t; for (t = (unsigned char *)p; *t; ++t) { if (isdigit(*t)) continue; badformat(); } tval = time(NULL); lt = localtime(&tval); lt->tm_sec = 0; lt->tm_min = 0; switch (strlen(p)) { case 10: /* yyyy */ bigyear = ATOI2(p); lt->tm_year = bigyear * 100 - 1900; yearset = 1; /* FALLTHROUGH */ case 8: /* yy */ if (yearset) { lt->tm_year += ATOI2(p); } else { lt->tm_year = ATOI2(p); if (lt->tm_year < 69) /* hack for 2000 */ lt->tm_year += 100; } /* FALLTHROUGH */ case 6: /* mm */ lt->tm_mon = ATOI2(p); if ((lt->tm_mon > 12) || !lt->tm_mon) badformat(); --lt->tm_mon; /* time struct is 0 - 11 */ /* FALLTHROUGH */ case 4: /* dd */ lt->tm_mday = ATOI2(p); if ((lt->tm_mday > 31) || !lt->tm_mday) badformat(); /* FALLTHROUGH */ case 2: /* HH */ lt->tm_hour = ATOI2(p); if (lt->tm_hour > 23) badformat(); break; default: badformat(); } /* The calling code needs a valid tm_ydays and this is the easiest * way to get one */ if ((tval = mktime(lt)) == -1) errx(1, "specified date is outside allowed range"); return (tval); } void badformat() { warnx("illegal time format"); (void)fprintf(stderr, "usage: pom [[[[[cc]yy]mm]dd]HH]\n"); exit(1); } bsd-games-2.17/pom/Makefile.bsd0000664000175000017500000000024606350047433015007 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.4 1995/03/23 08:35:33 cgd Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= pom MAN= pom.6 DPADD= ${LIBM} LDADD= -lm .include bsd-games-2.17/ChangeLog0000664000175000017500000061210310205245257013556 0ustar jsm28jsm282005-02-18 Joseph S. Myers * Version 2.17. * NEWS, bsd-games.lsm, bsd-games-non-free.lsm: Update. * wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. 2005-02-16 Joseph S. Myers * atc/input.c, backgammon/backgammon/main.c, backgammon/teachgammon/teach.c, cribbage/instr.c, fish/fish.c, phantasia/gamesupport.c, phantasia/interplayer.c, phantasia/io.c, phantasia/misc.c, phantasia/phantstruct.h, rogue/machdep.c, rogue/rogue.h, trek/getpar.h, trek/trek.h, wump/wump.c: Update from NetBSD CVS. 2005-02-14 Joseph S. Myers * hack/hack.termcap.c: Remove "static" from some variables. Fix from Andreas Jochens in Debian bug 284750. * exec.objs: Include lib/strlcpy.o for atc and sail. * atc/input.c, backgammon/backgammon/main.c, backgammon/teachgammon/teach.c, cribbage/instr.c, fish/fish.c, phantasia/misc.c, rogue/machdep.c, wump/wump.c: Cast last argument of execl to char *. * rogue/rogue.h: Avoid arrays of incomplete types. * trek/trek.h: Likewise. Don't declare Skitab and Lentab here. * trek/getpar.h: Declare Skitab and Lentab here. * phantasia/phantstruct.h: Define phbool. * phantasia/gamesupport.c, phantasia/interplayer.c, phantasia/io.c, phantasia/misc.c: Use phbool where necessary. * .cvsignore, adventure/.cvsignore, arithmetic/.cvsignore, atc/.cvsignore, backgammon/backgammon/.cvsignore, backgammon/common_source/.cvsignore, backgammon/teachgammon/.cvsignore, banner/.cvsignore, battlestar/.cvsignore, bcd/.cvsignore, boggle/boggle/.cvsignore, boggle/mkdict/.cvsignore, boggle/mkindex/.cvsignore, caesar/.cvsignore, canfield/canfield/.cvsignore, canfield/cfscores/.cvsignore, cribbage/.cvsignore, dab/.cvsignore, dm/.cvsignore, factor/.cvsignore, fish/.cvsignore, fortune/datfiles/.cvsignore, fortune/fortune/.cvsignore, fortune/strfile/.cvsignore, fortune/unstr/.cvsignore, gomoku/.cvsignore, hack/.cvsignore, hangman/.cvsignore, hunt/hunt/.cvsignore, hunt/huntd/.cvsignore, include/.cvsignore, lib/.cvsignore, mille/.cvsignore, monop/.cvsignore, morse/.cvsignore, number/.cvsignore, phantasia/.cvsignore, pig/.cvsignore, pom/.cvsignore, ppt/.cvsignore, primes/.cvsignore, quiz/.cvsignore, quiz/datfiles/.cvsignore, rain/.cvsignore, random/.cvsignore, robots/.cvsignore, rogue/.cvsignore, sail/.cvsignore, snake/snake/.cvsignore, snake/snscore/.cvsignore, tetris/.cvsignore, trek/.cvsignore, worm/.cvsignore, worms/.cvsignore, wtf/.cvsignore, wump/.cvsignore: Remove as no longer needed after move to Subversion. 2005-01-30 Joseph S. Myers * fortune/datfiles/fortunes2: Update from NetBSD CVS. 2005-01-30 Joseph S. Myers * wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. * COPYING: Update copyright dates. 2004-12-23 Joseph S. Myers * monop/malloc.c, phantasia/main.c, phantasia/setup.c: Update from NetBSD CVS. 2004-12-07 Joseph S. Myers * arithmetic/arithmetic.c, battlestar/getcom.c, boggle/boggle/bog.c, boggle/boggle/mach.c, canfield/canfield/canfield.c, cribbage/io.c, dm/dm.c, fortune/fortune/fortune.c, gomoku/stoc.c, hack/hack.u_init.c, hangman/getword.c, hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/huntd/answer.c, mille/move.c, monop/getinp.c, monop/misc.c, number/number.c, pig/pig.c, robots/main.c, sail/dr_1.c, sail/misc.c, sail/pl_4.c, sail/pl_5.c, worms/Makefile.bsd, wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. 2004-10-31 Joseph S. Myers * lib/fgetln.c: Handle case of line just fitting in buffer correctly. 2004-10-23 Joseph S. Myers * dm/utmpentry.c: Update from NetBSD CVS. 2004-09-15 Joseph S. Myers * fortune/fortune/fortune.6.in, fortune/strfile/strfile.8, worms/worms.c: Update from NetBSD CVS. 2004-09-08 Joseph S. Myers * atc/log.c, sail/dr_1.c, sail/sync.c: Update from NetBSD CVS. 2004-09-04 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 2004-09-02 Joseph S. Myers * robots/auto.c, robots/move.c: Update from NetBSD CVS. 2004-08-23 Joseph S. Myers * fortune/datfiles/fortunes: Update from NetBSD CVS. 2004-07-16 Joseph S. Myers * wtf/acronyms.comp: Update from NetBSD CVS. 2004-07-05 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 2004-06-07 Joseph S. Myers * wtf/acronyms.comp: Update from NetBSD CVS. 2004-06-02 Joseph S. Myers * hack/hack.6.in: Update from NetBSD CVS. 2004-05-24 Joseph S. Myers * fortune/datfiles/fortunes: Update from NetBSD CVS. 2004-05-20 Joseph S. Myers * wtf/acronyms.comp: Update from NetBSD CVS. 2004-05-02 Joseph S. Myers * rain/rain.c: Update from NetBSD CVS. * exec.objs: Update. 2004-04-30 Joseph S. Myers * wtf/acronyms.comp: Update from NetBSD CVS. 2004-04-24 Joseph S. Myers * backgammon/common_source/fancy.c, fortune/datfiles/farber: Update from NetBSD CVS. 2004-04-12 Joseph S. Myers * phantasia/fight.c, phantasia/gamesupport.c, phantasia/interplayer.c, phantasia/io.c, phantasia/main.c, phantasia/misc.c: Update from NetBSD CVS. 2004-04-08 Joseph S. Myers * mille/move.c, phantasia/fight.c, phantasia/gamesupport.c, phantasia/include.h, phantasia/interplayer.c, phantasia/io.c, phantasia/main.c, phantasia/misc.c, phantasia/phantstruct.h, phantasia/setup.c, worms/worms.c, wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. 2004-03-29 Joseph S. Myers * fortune/datfiles/fortunes2, fortune/datfiles/fortunes2-o.real, hack/data, hack/rumors: Update from NetBSD CVS. 2004-03-27 Joseph S. Myers * wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. 2004-03-12 Joseph S. Myers * wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. 2004-03-05 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 2004-03-04 Joseph S. Myers * wtf/acronyms.comp: Update from NetBSD CVS. 2004-02-28 Joseph S. Myers * fortune/datfiles/fortunes2: Update from NetBSD CVS. 2004-02-18 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 2004-02-14 Joseph S. Myers * fortune/datfiles/fortunes, fortune/datfiles/fortunes.sp.ok, rogue/USD.doc/rogue.me: Update from NetBSD CVS. * NEWS: Fix typo. * ChangeLog: Mark properly for 2.16 release. 2004-02-13 Joseph S. Myers * Version 2.16. * NEWS, bsd-games.lsm, bsd-games-non-free.lsm: Update. * morse/morse.c: Update from NetBSD CVS. * morse/morse.c: Encode and decode more characters. Don't put commas after every character. Don't encode whitespace as "...". Don't fail decoding across a 1024-byte boundary. Mark end of message appropriately. From OpenBSD but with punctuation taken from ITU-T Recommendation F.1 (03/98). * tests/morse.testsent, tests/morse.testsentd: New tests. * tests/morse.SOS, tests/morse.foo, tests/morse.sos: Update. * tests/morse.test: Update. 2004-02-11 Joseph S. Myers * tests/pom.2003fm1, tests/pom.2003fm2, tests/pom.2003fq1, tests/pom.2003fq2, tests/pom.2003lq1, tests/pom.2003lq2, tests/pom.2003nm1, tests/pom.2003nm2, tests/pom.2003ph1, tests/pom.2003ph2, tests/pom.2003ph3, tests/pom.2003ph4, tests/pom.2003ph5, tests/pom.2003ph6, tests/pom.2003ph7, tests/pom.2003ph8: New tests. * tests/pom.test: Update. 2004-02-10 Joseph S. Myers * primes/primes.6: Update from NetBSD CVS. 2004-02-09 Joseph S. Myers * configure: Ask for a documentation directory if building trek or rogue. * Makeconfig.in (DOCDIR): Define. * substfiles2: Add trek/trek.6. * trek/trek.6: Rename to trek/trek.6.in. * trek/trek.6.in: Mark documentation directory for substitution. * rogue/Makefrag, trek/Makefrag: Install USD documents. * INSTALL, PACKAGING, README: Update. 2004-02-08 Joseph S. Myers * backgammon/backgammon/main.c, backgammon/teachgammon/teach.c, cribbage/cribbage.h, dm/dm.c, fortune/unstr/unstr.c, hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/huntd/faketalk.c, hunt/huntd/hunt.h, phantasia/Makefile.bsd, rain/rain.c, worms/worms.c: Update from NetBSD CVS. * rain/rain.c, worms/worms.c: Hide the cursor with curs_set(0). From OpenBSD. * tests/factor.8675309, tests/factor.6172538568: New tests (from NetBSD src/regress). * tests/factor.test: Update. * boggle/README.linux, dm/README.linux, fortune/README.linux, hunt/README.linux, trek/README.linux: Remove. * README: Move information from those files to here. * INSTALL: Update. * COPYING: Update. * factor/Makefile.bsd, factor/factor.6, factor/factor.c, primes/Makefile.bsd, primes/primes.6: Update from NetBSD CVS. * TODO: Update. * substscr: Explicitly set execute permissions from those of source file. * primes/primes.6: Separate manpage from that of factor. * primes/Makefrag: Update. * factor/factor.6: Change to be a manpage for factor only. * factor/factor.c: Only use Pollard p-1 if remaining factor isn't prime. Correct comment. Increase base if p-1 algorithm reaches 1. * tests/factor.2147483647111311, tests/factor.99999999999991: New tests. * tests/factor.test: Update. Bugs reported by David A Bagley . * countmail/countmail.6, phantasia/fight.c, phantasia/io.c, sail/extern.h, sail/misc.c, snake/snake/snake.c: Update from NetBSD CVS. 2004-01-27 Joseph S. Myers * dab/.cvsignore: New file. * Makeconfig.in: Add STRLCPY_DEFS and GETPROGNAME_DEFS. * arithmetic/Makefrag, fortune/fortune/Makefrag, rogue/Makefrag: Use them. * dm/utmpentry.c, dm/utmpentry.h: New from NetBSD CVS of usr.bin/who. * COPYING: Update. * dm/dm.c: Follow NetBSD in use of this utmp handling. * dm/Makefrag: Update. * exec.objs: Update. * lib/getprogname.c: New file. * include/stdlib.h: Update. * configure: Check for getprogname. * arithmetic/arithmetic.c, fortune/fortune/fortune.c: Follow NetBSD in use of getprogname(). * exec.objs: Update. * adventure/extern.h, adventure/main.c, arithmetic/arithmetic.c, atc/extern.h, atc/input.c, backgammon/backgammon/backlocal.h, backgammon/backgammon/move.c, backgammon/common_source/back.h, backgammon/teachgammon/tutor.h, banner/banner.c, battlestar/battlestar.c, battlestar/extern.h, battlestar/fly.c, battlestar/init.c, battlestar/parse.c, bcd/bcd.c, boggle/boggle/bog.c, boggle/boggle/extern.h, boggle/boggle/mach.c, boggle/boggle/prtable.c, boggle/boggle/timer.c, caesar/caesar.c, canfield/canfield/canfield.c, canfield/cfscores/cfscores.c, cribbage/crib.c, cribbage/cribbage.h, dm/dm.c, fish/fish.c, fortune/fortune/fortune.c, fortune/unstr/unstr.c, gomoku/gomoku.h, gomoku/main.c, gomoku/pickmove.c, hack/def.func_tab.h, hack/extern.h, hack/hack.apply.c, hack/hack.do.c, hack/hack.h, hack/hack.invent.c, hack/hack.main.c, hack/hack.shk.c, hack/hack.vault.c, hack/hack.zap.c, hangman/hangman.h, hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/hunt/playit.c, hunt/huntd/driver.c, hunt/huntd/execute.c, hunt/huntd/expl.c, hunt/huntd/faketalk.c, hunt/huntd/hunt.h, hunt/huntd/makemaze.c, hunt/huntd/shots.c, hunt/huntd/talk_ctl.h, mille/mille.h, mille/table.c, mille/varpush.c, monop/cards.c, monop/execute.c, monop/getinp.c, monop/houses.c, monop/malloc.c, monop/monop.c, monop/monop.def, monop/monop.ext, monop/monop.h, monop/morg.c, monop/print.c, monop/prop.c, monop/trade.c, morse/morse.c, number/number.c, pig/pig.c, pom/pom.c, ppt/ppt.c, primes/primes.c, quiz/quiz.c, quiz/quiz.h, quiz/rxp.c, rain/rain.c, random/random.c, robots/auto.c, robots/main.c, robots/robots.h, robots/score.c, rogue/main.c, rogue/rogue.h, sail/extern.h, sail/pl_1.c, sail/sync.c, snake/snake/snake.c, snake/snscore/snscore.c, tetris/input.h, tetris/scores.c, tetris/scores.h, tetris/screen.c, tetris/screen.h, tetris/tetris.c, tetris/tetris.h, trek/compkl.c, trek/computer.c, trek/dumpgame.c, trek/getpar.c, trek/getpar.h, trek/main.c, trek/torped.c, trek/trek.h, worm/worm.c, worms/worms.c, wump/wump.c: Update from NetBSD CVS. * adventure/extern.h, adventure/main.c, arithmetic/arithmetic.c, atc/extern.h, atc/input.c, backgammon/backgammon/backlocal.h, backgammon/backgammon/move.c, backgammon/common_source/back.h, backgammon/teachgammon/tutor.h, banner/banner.c, battlestar/battlestar.c, battlestar/extern.h, battlestar/fly.c, battlestar/init.c, battlestar/parse.c, bcd/bcd.c, boggle/boggle/bog.c, boggle/boggle/extern.h, boggle/boggle/mach.c, boggle/boggle/prtable.c, boggle/boggle/timer.c, caesar/caesar.c, canfield/canfield/canfield.c, canfield/cfscores/cfscores.c, cribbage/crib.c, cribbage/cribbage.h, dm/dm.c, fish/fish.c, fortune/fortune/fortune.c, fortune/unstr/unstr.c, gomoku/gomoku.h, gomoku/main.c, hack/def.func_tab.h, hack/extern.h, hack/hack.apply.c, hack/hack.do.c, hack/hack.h, hack/hack.invent.c, hack/hack.main.c, hack/hack.shk.c, hack/hack.vault.c, hack/hack.zap.c, hangman/hangman.h, hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/hunt/playit.c, hunt/huntd/driver.c, hunt/huntd/execute.c, hunt/huntd/expl.c, hunt/huntd/faketalk.c, hunt/huntd/hunt.h, hunt/huntd/makemaze.c, hunt/huntd/shots.c, hunt/huntd/talk_ctl.h, mille/mille.h, mille/table.c, mille/varpush.c, monop/cards.c, monop/execute.c, monop/getinp.c, monop/houses.c, monop/monop.c, monop/monop.def, monop/monop.ext, monop/monop.h, monop/morg.c, monop/print.c, monop/prop.c, monop/trade.c, monop/malloc.c, morse/morse.c, number/number.c, pig/pig.c, pom/pom.c, ppt/ppt.c, primes/primes.c, quiz/quiz.c, quiz/quiz.h, quiz/rxp.c, rain/rain.c, random/random.c, robots/auto.c, robots/main.c, robots/robots.h, robots/score.c, rogue/main.c, rogue/rogue.h, snake/snake/snake.c, snake/snscore/snscore.c, tetris/input.h, tetris/scores.c, tetris/scores.h, tetris/screen.c, tetris/screen.h, tetris/tetris.c, tetris/tetris.h, trek/compkl.c, trek/computer.c, trek/dumpgame.c, trek/getpar.c, trek/getpar.h, trek/main.c, trek/torped.c, trek/trek.h, worm/worm.c, worms/worms.c, wump/wump.c: Remove uses of __P. * THANKS: Mention David A Bagley. * sail/pl_1.c (child): Use int for wait status. * gomoku/gomoku.h, robots/robots.h, sail/extern.h, sail/misc.c, sail/sync.c: Adjust system header includes. * fortune/fortune/fortune.6.in: Update substitution for path to fortunes directory. * cribbage/crib.c, cribbage/cribbage.h, cribbage/io.c, dab/Makefile.bsd, monop/misc.c, monop/monop.def, monop/monop.ext: Update from NetBSD CVS. 2004-01-26 Joseph S. Myers * sail/main.c: Reorder includes to match NetBSD. * cribbage/cribbage.h, cribbage/crib.c, cribbage/io.c: Rename receive_int to receive_intr. * hack/hack.pri.c: Fix typo in merge from NetBSD. * configure: Consistently use balanced parentheses in case statements. 2004-01-25 Joseph S. Myers * monop/misc.c, monop/monop.def, monop/monop.ext: Rename yn to yncoms. * cribbage/cribbage.h, cribbage/crib.c, cribbage/io.c: Rename rint to receive_int. * fortune/fortune/fortune.c: Add test for __CYGWIN__. * configure: Test for sig_t. * include/signal.h: Use it. Cygwin issues reported by David A Bagley . 2004-01-16 Joseph S. Myers * wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. 2004-01-14 Joseph S. Myers * wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. 2004-01-04 Joseph S. Myers * COPYING: Note that TODO no longer contains anything from the original bsd-games 1.3. * phantasia/phantasia.6, wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS. 2004-01-02 Joseph S. Myers * atc/atc.6.in, backgammon/backgammon/main.c, backgammon/teachgammon/data.c, caesar/caesar.c, fortune/datfiles/fortunes, fortune/datfiles/fortunes2, fortune/fortune/fortune.c, hack/hack.options.c, phantasia/main.c, phantasia/misc.c, rogue/Makefile.bsd, rogue/rogue.h, wargames/wargames.6, worm/worm.6, wtf/acronyms: Update from NetBSD CVS. * dab: New directory from NetBSD CVS. * COPYING, INSTALL, README, bsd-games.lsm, Makeconfig.in, configure, exec.libs, exec.objs: Update. * dab/Makefrag: New file. 2003-12-18 Joseph S. Myers * Version 2.15. * NEWS, bsd-games.lsm, bsd-games-non-free.lsm: Update. * README: Update. 2003-12-17 Joseph S. Myers * backgammon/backgammon/main.c (main): Only score as a Gammon or a Backgammon if the opponent hasn't removed any pieces, not if the opponent has removed pieces but has had a piece knocked back to the bar afterwards. Fixes Debian bug 185101 from Konstantin Seiler . * fortune/fortune/fortune.c (fortlen): Return proper fortune length for fortune files without STR_RANDOM or STR_ORDERED rather than comparing it to SLEN. Bug reported by Simon Williams . * fortune/fortune/fortune.c (init_prob): Show residual probability rather than non-residual in "No place to put residual probability" error message. Distribute residual probability correctly rather than all to one file. Patch from Mike Castle . * configure, Makeconfig.in, fortune/fortune/pathnames.h.in, fortune/datfiles/Makefrag: Make fortune directory configurable; default to NetBSD default. * rogue/Makefrag: Don't use -fwritable-strings. * rogue/rogue.h (struct id): Add const. * TODO: Update. * backgammon/teachgammon/data.c: Make tutorial text match actual moves. From FreeBSD via OpenBSD. Fixes Debian bug 212478 from Jim W. Jaszewski . * adventure/glorkz: Fix capitalisation of compass directions. * phantasia/main.c (cleanup): Only close files that have been opened successfully. * phantasic/misc.c (error): Give error text rather than errno number. Patch from Joey Hess for Debian bug 187251 from Mikael Hedin . * wtf/acronyms: Add two acronyms suggested by Pavel Machek . * wargames/wargames.6: Fix typo. Patch from Joey Hess . * hack/hack.options.c (parseoptions): Refer to 'O' rather than 'o' as command to set options. Bug reported by Christian Garbs in Debian bug 191452. * caesar/caesar.c (main): Make dot and winnerdot of type double. Patch from Jan Vornberger in Debian bug 197816. * tests/caesar.197816in, tests/caesar.197816out: New tests. * tests/caesar.test: Update. * worm/worm.6: Score is in upper right corner, not upper left corner. Patch from Robert Hunter in Debian bug 209034. * atc/atc.6.in: Document that pressing return allows you to "fast forward" the game clock. Patch from Peter Maydell in Debian bug 216980. * PACKAGING: Remove some old version references. * INSTALL: Simplify and remove some obsolete information. * adventure/Makefile.bsd, adventure/adventure.6, adventure/crc.c, adventure/done.c, adventure/hdr.h, adventure/init.c, adventure/io.c, adventure/main.c, adventure/save.c, adventure/setup.c, adventure/subr.c, adventure/vocab.c, adventure/wizard.c, arithmetic/arithmetic.6, arithmetic/arithmetic.c, atc/Makefile.bsd, atc/atc.6.in, atc/def.h, atc/extern.c, atc/extern.h, atc/grammar.y, atc/graphics.c, atc/include.h, atc/input.c, atc/lex.l, atc/list.c, atc/log.c, atc/main.c, atc/pathnames.h.in, atc/struct.h, atc/tunable.c, atc/tunable.h, atc/update.c, backgammon/backgammon/backgammon.6.in, backgammon/backgammon/extra.c, backgammon/backgammon/main.c, backgammon/backgammon/move.c, backgammon/backgammon/text.c, backgammon/backgammon/version.c, backgammon/common_source/allow.c, backgammon/common_source/back.h, backgammon/common_source/board.c, backgammon/common_source/check.c, backgammon/common_source/fancy.c, backgammon/common_source/init.c, backgammon/common_source/odds.c, backgammon/common_source/one.c, backgammon/common_source/save.c, backgammon/common_source/subs.c, backgammon/common_source/table.c, backgammon/teachgammon/data.c, backgammon/teachgammon/teach.c, backgammon/teachgammon/ttext1.c, backgammon/teachgammon/ttext2.c, backgammon/teachgammon/tutor.c, backgammon/teachgammon/tutor.h, banner/banner.6, banner/banner.c, battlestar/battlestar.6, battlestar/battlestar.c, battlestar/command1.c, battlestar/command2.c, battlestar/command3.c, battlestar/command4.c, battlestar/command5.c, battlestar/command6.c, battlestar/command7.c, battlestar/cypher.c, battlestar/dayfile.c, battlestar/dayobjs.c, battlestar/extern.h, battlestar/fly.c, battlestar/getcom.c, battlestar/globals.c, battlestar/init.c, battlestar/misc.c, battlestar/nightfile.c, battlestar/nightobjs.c, battlestar/parse.c, battlestar/pathnames.h.in, battlestar/room.c, battlestar/save.c, battlestar/words.c, bcd/bcd.6, bcd/bcd.c, boggle/Makefile.bsd, boggle/boggle/bog.c, boggle/boggle/bog.h.in, boggle/boggle/boggle.6, boggle/boggle/extern.h, boggle/boggle/help.c, boggle/boggle/mach.c, boggle/boggle/prtable.c, boggle/boggle/timer.c, boggle/boggle/word.c, boggle/mkdict/mkdict.c, boggle/mkindex/mkindex.c, caesar/caesar.6, caesar/caesar.c, canfield/canfield/canfield.6.in, canfield/canfield/canfield.c, canfield/canfield/pathnames.h.in, canfield/cfscores/cfscores.c, countmail/countmail.6, cribbage/cards.c, cribbage/crib.c, cribbage/cribbage.6.in, cribbage/cribbage.h, cribbage/cribcur.h, cribbage/deck.h, cribbage/extern.c, cribbage/instr.c, cribbage/io.c, cribbage/pathnames.h.in, cribbage/score.c, cribbage/support.c, dm/dm.8.in, dm/dm.c, dm/dm.conf.5.in, dm/pathnames.h.in, factor/factor.6, factor/factor.c, fish/fish.6, fish/fish.c, fish/pathnames.h.in, fortune/datfiles/Makefile.bsd, fortune/datfiles/farber, fortune/datfiles/fortunes, fortune/datfiles/fortunes-o.real, fortune/datfiles/fortunes2, fortune/datfiles/fortunes2-o.real, fortune/datfiles/limerick, fortune/datfiles/limerick-o.real, fortune/datfiles/netbsd, fortune/datfiles/netbsd-o.real, fortune/datfiles/startrek, fortune/datfiles/startrek.sp.ok, fortune/datfiles/zippy, fortune/datfiles/zippy.sp.ok, fortune/fortune/fortune.6.in, fortune/fortune/fortune.c, fortune/fortune/pathnames.h.in, fortune/strfile/strfile.8, fortune/strfile/strfile.c, fortune/strfile/strfile.h, fortune/unstr/unstr.c, gomoku/bdinit.c, gomoku/bdisp.c, gomoku/gomoku.6, gomoku/gomoku.h, gomoku/main.c, gomoku/makemove.c, gomoku/pickmove.c, gomoku/stoc.c, hack/COPYRIGHT, hack/COPYRIGHT-JF, hack/Makefile.bsd, hack/alloc.c, hack/config.h, hack/date.h, hack/def.edog.h, hack/def.eshk.h, hack/def.flag.h, hack/def.func_tab.h, hack/def.gen.h, hack/def.gold.h, hack/def.mkroom.h, hack/def.monst.h, hack/def.obj.h, hack/def.objclass.h, hack/def.objects.h, hack/def.permonst.h, hack/def.rm.h, hack/def.trap.h, hack/def.wseg.h, hack/hack.6.in, hack/hack.Decl.c, hack/hack.apply.c, hack/hack.bones.c, hack/hack.c, hack/hack.cmd.c, hack/hack.do.c, hack/hack.do_name.c, hack/hack.do_wear.c, hack/hack.dog.c, hack/hack.eat.c, hack/hack.end.c, hack/hack.engrave.c, hack/hack.fight.c, hack/hack.h, hack/hack.invent.c, hack/hack.ioctl.c, hack/hack.lev.c, hack/hack.main.c, hack/hack.makemon.c, hack/hack.mfndpos.h, hack/hack.mhitu.c, hack/hack.mklev.c, hack/hack.mkmaze.c, hack/hack.mkobj.c, hack/hack.mkshop.c, hack/hack.mon.c, hack/hack.monst.c, hack/hack.o_init.c, hack/hack.objnam.c, hack/hack.options.c, hack/hack.pager.c, hack/hack.potion.c, hack/hack.pri.c, hack/hack.read.c, hack/hack.rip.c, hack/hack.rumors.c, hack/hack.save.c, hack/hack.search.c, hack/hack.sh, hack/hack.shk.c, hack/hack.shknam.c, hack/hack.steal.c, hack/hack.termcap.c, hack/hack.timeout.c, hack/hack.topl.c, hack/hack.track.c, hack/hack.trap.c, hack/hack.tty.c, hack/hack.u_init.c, hack/hack.unix.c, hack/hack.vault.c, hack/hack.version.c, hack/hack.wield.c, hack/hack.wizard.c, hack/hack.worm.c, hack/hack.worn.c, hack/hack.zap.c, hack/makedefs.c, hack/pathnames.h.in, hack/rnd.c, hangman/endgame.c, hangman/extern.c, hangman/getguess.c, hangman/getword.c, hangman/hangman.6.in, hangman/hangman.h, hangman/main.c, hangman/pathnames.h.in, hangman/playgame.c, hangman/prdata.c, hangman/prman.c, hangman/prword.c, hangman/setup.c, hunt/Makefile.inc.bsd, hunt/hunt/connect.c, hunt/hunt/hunt.6.in, hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/hunt/playit.c, hunt/huntd/answer.c, hunt/huntd/bsd.h, hunt/huntd/ctl.c, hunt/huntd/ctl_transact.c, hunt/huntd/draw.c, hunt/huntd/driver.c, hunt/huntd/execute.c, hunt/huntd/expl.c, hunt/huntd/extern.c, hunt/huntd/faketalk.c, hunt/huntd/get_names.c, hunt/huntd/hunt.h, hunt/huntd/huntd.6.in, hunt/huntd/makemaze.c, hunt/huntd/pathname.c, hunt/huntd/shots.c, hunt/huntd/talk_ctl.h, hunt/huntd/terminal.c, mille/comp.c, mille/end.c, mille/extern.c, mille/init.c, mille/mille.6, mille/mille.c, mille/mille.h, mille/misc.c, mille/move.c, mille/print.c, mille/roll.c, mille/save.c, mille/table.c, mille/types.c, mille/varpush.c, monop/Makefile.bsd, monop/brd.dat, monop/cards.c, monop/deck.h, monop/execute.c, monop/getinp.c, monop/houses.c, monop/initdeck.c, monop/jail.c, monop/malloc.c, monop/misc.c, monop/mon.dat, monop/monop.6.in, monop/monop.c, monop/monop.def, monop/monop.ext, monop/monop.h, monop/morg.c, monop/pathnames.h.in, monop/print.c, monop/prop.c, monop/prop.dat, monop/rent.c, monop/roll.c, monop/spec.c, monop/trade.c, morse/morse.c, number/number.6, number/number.c, phantasia/Makefile.bsd, phantasia/main.c, phantasia/misc.c, phantasia/pathnames.h.in, phantasia/phantasia.6, phantasia/phantglobs.h, phantasia/setup.c, pig/pig.6, pig/pig.c, pom/pom.6, pom/pom.c, ppt/ppt.c, primes/pattern.c, primes/pr_tbl.c, primes/primes.c, primes/primes.h, quiz/pathnames.h.in, quiz/quiz.6.in, quiz/quiz.c, quiz/quiz.h, quiz/rxp.c, rain/rain.6, rain/rain.c, random/random.6, random/random.c, robots/extern.c, robots/flush_in.c, robots/init_field.c, robots/main.c, robots/make_level.c, robots/move.c, robots/move_robs.c, robots/pathnames.h.in, robots/play_level.c, robots/query.c, robots/rnd_pos.c, robots/robots.6.in, robots/robots.h, robots/score.c, rogue/USD.doc/Makefile.bsd, rogue/USD.doc/rogue.me, rogue/hit.c, rogue/init.c, rogue/inventory.c, rogue/level.c, rogue/machdep.c, rogue/main.c, rogue/message.c, rogue/monster.c, rogue/move.c, rogue/object.c, rogue/pack.c, rogue/pathnames.h.in, rogue/play.c, rogue/random.c, rogue/ring.c, rogue/rogue.6.in, rogue/rogue.h, rogue/room.c, rogue/save.c, rogue/score.c, rogue/spec_hit.c, rogue/throw.c, rogue/trap.c, rogue/use.c, rogue/zap.c, sail/assorted.c, sail/dr_1.c, sail/dr_2.c, sail/dr_3.c, sail/dr_4.c, sail/dr_5.c, sail/dr_main.c, sail/driver.h, sail/extern.h, sail/game.c, sail/globals.c, sail/lo_main.c, sail/machdep.h, sail/main.c, sail/misc.c, sail/parties.c, sail/pathnames.h.in, sail/pl_1.c, sail/pl_2.c, sail/pl_3.c, sail/pl_4.c, sail/pl_5.c, sail/pl_6.c, sail/pl_7.c, sail/pl_main.c, sail/player.h, sail/sail.6, sail/sync.c, sail/version.c, snake/snake/pathnames.h.in, snake/snake/snake.6.in, snake/snake/snake.c, snake/snscore/snscore.c, tetris/input.c, tetris/input.h, tetris/pathnames.h.in, tetris/scores.c, tetris/scores.h, tetris/screen.c, tetris/screen.h, tetris/shapes.c, tetris/tetris.6.in, tetris/tetris.c, tetris/tetris.h, trek/USD.doc/Makefile.bsd, trek/USD.doc/trek.me, trek/abandon.c, trek/attack.c, trek/autover.c, trek/capture.c, trek/cgetc.c, trek/check_out.c, trek/checkcond.c, trek/compkl.c, trek/computer.c, trek/damage.c, trek/damaged.c, trek/dcrept.c, trek/destruct.c, trek/dock.c, trek/dumpgame.c, trek/dumpme.c, trek/dumpssradio.c, trek/events.c, trek/externs.c, trek/getcodi.c, trek/getpar.c, trek/getpar.h, trek/help.c, trek/impulse.c, trek/initquad.c, trek/kill.c, trek/klmove.c, trek/lose.c, trek/lrscan.c, trek/main.c, trek/move.c, trek/nova.c, trek/out.c, trek/phaser.c, trek/play.c, trek/ram.c, trek/ranf.c, trek/rest.c, trek/schedule.c, trek/score.c, trek/setup.c, trek/setwarp.c, trek/shield.c, trek/snova.c, trek/srscan.c, trek/systemname.c, trek/torped.c, trek/trek.6, trek/trek.h, trek/visual.c, trek/warp.c, trek/win.c, worm/worm.6, worm/worm.c, worms/worms.6, worms/worms.c, wtf/wtf.in, wtf/wtf.6.in, wump/pathnames.h.in, wump/wump.6, wump/wump.c: Update from NetBSD CVS. * wtf/acronyms: Update from NetBSD CVS. * wtf/acronyms.comp: New file from NetBSD CVS. * wtf/Makefrag: Update. * COPYING: Update. * INSTALL: Note that glibc 2.3 now required at least for hunt (for ). 2003-11-08 Joseph S. Myers * THANKS: Update Malcolm Parsons's email address. 2003-04-01 Joseph S. Myers * Version 2.14. * configure: Fix bug in OpenSSL support. * NEWS, bsd-games.lsm, bsd-games-non-free.lsm: Update. * configure, Makeconfig.in, exec.libs: Support OpenSSL for factor. * INSTALL: Update. * tests/factor.987654321987654, tests/factor.987654321987654321987: New files. * tests/factor.test: Update. 2003-03-29 Joseph S. Myers * hack/COPYRIGHT, hack/COPYRIGHT-JF, hack/alloc.c, hack/config.h, hack/date.h, hack/def.edog.h, hack/def.eshk.h, hack/def.flag.h, hack/def.func_tab.h, hack/def.gen.h, hack/def.gold.h, hack/def.mkroom.h, hack/def.monst.h, hack/def.obj.h, hack/def.objclass.h, hack/def.objects.h, hack/def.permonst.h, hack/def.rm.h, hack/def.trap.h, hack/def.wseg.h, hack/hack.6.in, hack/hack.Decl.c, hack/hack.apply.c, hack/hack.bones.c, hack/hack.c, hack/hack.cmd.c, hack/hack.do.c, hack/hack.do_name.c, hack/hack.do_wear.c, hack/hack.dog.c, hack/hack.eat.c, hack/hack.end.c, hack/hack.engrave.c, hack/hack.fight.c, hack/hack.h, hack/hack.invent.c, hack/hack.ioctl.c, hack/hack.lev.c, hack/hack.main.c, hack/hack.makemon.c, hack/hack.mfndpos.h, hack/hack.mhitu.c, hack/hack.mklev.c, hack/hack.mkmaze.c, hack/hack.mkobj.c, hack/hack.mkshop.c, hack/hack.mon.c, hack/hack.monst.c, hack/hack.o_init.c, hack/hack.objnam.c, hack/hack.options.c, hack/hack.pager.c, hack/hack.potion.c, hack/hack.pri.c, hack/hack.read.c, hack/hack.rip.c, hack/hack.rumors.c, hack/hack.save.c, hack/hack.search.c, hack/hack.sh, hack/hack.shk.c, hack/hack.shknam.c, hack/hack.steal.c, hack/hack.termcap.c, hack/hack.timeout.c, hack/hack.topl.c, hack/hack.track.c, hack/hack.trap.c, hack/hack.tty.c, hack/hack.u_init.c, hack/hack.unix.c, hack/hack.vault.c, hack/hack.version.c, hack/hack.wield.c, hack/hack.wizard.c, hack/hack.worm.c, hack/hack.worn.c, hack/hack.zap.c, hack/makedefs.c, hack/rnd.c: Hack is now BSD-licensed. Thanks to Andries Brouwer, Jay Fenlason and CWI . Via OpenBSD. * COPYING, README, README.non-free, bsd-games.lsm, bsd-games-non-free.lsm: Update. * quiz/datfiles/europe: Yugoslavia has changed its name to Serbia and Montenegro. * quiz/datfiles/europe: The Hague is not the capital of the Netherlands. Reported by Hugo van Galen (in the Netherlands) and Florian Boehl . 2003-03-28 Joseph S. Myers * Makefile.bsd, Makefile.inc.bsd, adventure/Makefile.bsd, arithmetic/arithmetic.6, arithmetic/arithmetic.c, atc/atc.6.in, backgammon/backgammon/backgammon.6.in, backgammon/common_source/Makefile.bsd, backgammon/teachgammon/Makefile.bsd, banner/banner.6, battlestar/battlestar.6, bcd/bcd.6, boggle/Makefile.bsd, boggle/boggle/boggle.6, boggle/boggle/timer.c, boggle/mkdict/Makefile.bsd, boggle/mkindex/Makefile.bsd, caesar/caesar.6, canfield/canfield/canfield.6.in, canfield/cfscores/Makefile.bsd, countmail/countmail, countmail/countmail.6, cribbage/cribbage.6.in, cribbage/cribbage.h, cribbage/extern.c, cribbage/io.c, cribbage/score.c, cribbage/support.c, dm/Makefile.bsd, dm/dm.8.in, dm/dm.c, dm/dm.conf.5.in, factor/Makefile.bsd, factor/factor.6, factor/factor.c, fortune/datfiles/Makefile.bsd, fortune/datfiles/fortunes, fortune/datfiles/fortunes2, fortune/datfiles/fortunes2-o.real, fortune/datfiles/limerick, fortune/datfiles/netbsd, fortune/fortune/fortune.6.in, fortune/fortune/fortune.c, fortune/strfile/strfile.8, fortune/unstr/Makefile.bsd, gomoku/gomoku.6, hack/Makefile.bsd, hack/extern.h, hack/hack.6.in, hack/hack.main.c, hack/hack.mkshop.c, hack/hack.pri.c, hack/hack.topl.c, hack/hack.tty.c, hack/help, hangman/hangman.6.in, hunt/Makefile.inc.bsd, hunt/hunt/hunt.6.in, hunt/hunt/hunt.c, hunt/hunt/playit.c, hunt/huntd/answer.c, hunt/huntd/bsd.h, hunt/huntd/ctl_transact.c, hunt/huntd/driver.c, hunt/huntd/extern.c, hunt/huntd/faketalk.c, hunt/huntd/hunt.h, hunt/huntd/huntd.6.in, hunt/huntd/terminal.c, mille/mille.6, mille/misc.c, monop/Makefile.bsd, monop/cards.c, monop/getinp.c, monop/monop.6.in, monop/roll.c, morse/Makefile.bsd, phantasia/Makefile.bsd, phantasia/misc.c, phantasia/phantasia.6, pom/pom.6, ppt/Makefile.bsd, ppt/ppt.c, primes/Makefile.bsd, quiz/datfiles/posneg, quiz/quiz.6.in, quiz/rxp.c, rain/rain.6, random/random.6, robots/auto.c, robots/init_field.c, robots/move.c, robots/robots.6.in, robots/robots.h, rogue/Makefile.bsd, rogue/USD.doc/Makefile.bsd, rogue/hit.c, rogue/inventory.c, rogue/level.c, rogue/message.c, rogue/rogue.6.in, rogue/rogue.h, rogue/save.c, rogue/score.c, sail/sail.6, snake/snake/snake.6.in, snake/snscore/Makefile.bsd, tetris/input.c, tetris/scores.c, tetris/screen.c, tetris/shapes.c, tetris/tetris.6.in, tetris/tetris.c, trek/USD.doc/Makefile.bsd, trek/damage.c, trek/getpar.c, trek/trek.6.in, wargames/wargames.6, worm/worm.6, worms/worms.6, wtf/acronyms, wtf/wtf.in, wtf/wtf.6.in: Update from NetBSD CVS. * include/sys/poll.h: New file. * lib/strlcpy.c: New file. * configure: Test for strlcpy. * include/string.h: New file. * exec.objs: Use it for rogue. * trek/trek.6.in: Rename to trek.6. * substfiles2: Update. * COPYING: Update. * INSTALL: No longer suggest not using groff's macros. * PACKAGING: Update. * SECURITY: Update. 2002-06-18 Joseph S. Myers * BUGS, ChangeLog, INSTALL, README, README.non-free, SECURITY, TODO, bsd-games-non-free.lsm, bsd-games.lsm, dm/README.linux, hunt/README.linux, trek/README.linux: Consistently use jsm@polyomino.org.uk as email address. 2002-01-26 Joseph S. Myers * hangman/extern.c, hangman/getword.c, hangman/hangman.6.in, hangman/hangman.h, hangman/main.c: Update from NetBSD CVS. 2002-01-20 Joseph S. Myers * README: Note this collection supports GNU Hurd as well as Linux. * COPYING: Update. 2002-01-19 Joseph S. Myers * phantasia/fight.c (encounter): Make firsthit and flockcnt volatile. * backgammon/common_source/Makefile.bsd, backgammon/teachgammon/Makefile.bsd, boggle/mkdict/Makefile.bsd, boggle/mkindex/Makefile.bsd, canfield/cfscores/Makefile.bsd, fortune/datfiles/netbsd, fortune/fortune/fortune.c, fortune/unstr/Makefile.bsd, morse/Makefile.bsd, number/number.6, phantasia/Makefile.bsd, ppt/Makefile.bsd, primes/Makefile.bsd, snake/snscore/Makefile.bsd, wtf/acronyms: Update from NetBSD CVS. * hangman/main.c: Include . * hangman/extern.c, hangman/getword.c, hangman/hangman.6.in, hangman/hangman.h, hangman/main.c: Allow minimum word length to be set on the command line. Patch from Joey Hess . * COPYING: Update. 2001-12-29 Joseph S. Myers * phantasia/Makefrag (phantasia_install): Use $(INSTALL_PREFIX) when copying score files. Patch from Joey Hess . * AUTHORS, THANKS: Update email address for Joey Hess. Patch from Joey Hess . 2001-12-08 Joseph S. Myers * battlestar/fly.c, cribbage/crib.c, fortune/datfiles/fortunes2, fortune/datfiles/fortunes2-o.real, hangman/setup.c, mille/mille.c, phantasia/Makefile.bsd, phantasia/main.c, robots/main.c, rogue/init.c, sail/pl_7.c, worm/worm.c, wtf/acronyms: Update from NetBSD CVS. 2001-11-18 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. * battlestar/com1.c: Rename to battlestar/command1.c. * battlestar/com2.c: Rename to battlestar/command2.c. * battlestar/com3.c: Rename to battlestar/command3.c. * battlestar/com4.c: Rename to battlestar/command4.c. * battlestar/com5.c: Rename to battlestar/command5.c. * battlestar/com6.c: Rename to battlestar/command6.c. * battlestar/com7.c: Rename to battlestar/command7.c. From NetBSD CVS. * exec.objs: Update. * battlestar/Makefile.bsd, battlestar/command1.c, battlestar/command2.c, battlestar/command3.c, battlestar/command4.c, battlestar/command5.c, battlestar/command6.c, battlestar/command7.c, fortune/datfiles/Makefile.bsd, fortune/datfiles/limerick, fortune/fortune/fortune.c, hack/hack.termcap.c, tetris/screen.c: Update from NetBSD CVS. * fortune/datfiles/farber: New file. From NetBSD CVS. * fortune/datfiles/Makefrag: Update. * tetris/screen.c (scr_set): Set VMIN and VTIME. 2001-10-06 Joseph S. Myers * backgammon/backgammon/main.c, hack/hack.fix, monop/monop.c, phantasia/phantdefs.h, sail/pl_7.c, wargames/wargames: Update from NetBSD CVS. * hunt/hunt/hunt.6.in: Correct slime costs. Bug reported by Britton Leo Kerin . 2001-09-02 Joseph S. Myers * adventure/setup.c, atc/include.h, boggle/mkdict/mkdict.c, fortune/datfiles/fortunes, fortune/datfiles/fortunes-o.real, monop/execute.c, sail/main.c, snake/snake/snake.c, worm/worm.6, worm/worm.c, wump/wump.c, wtf/acronyms: Update from NetBSD CVS. 2001-08-30 Joseph S. Myers * Version 2.13. * COPYING, NEWS, TODO, bsd-games-non-free.lsm, bsd-games.lsm: Update. * phantasia/Makefrag: Update copyright dates. * hunt/hunt/hunt.c, hunt/huntd/get_names.c: Define MAXHOSTNAMELEN if not already defined. May fix Hurd compilation (original patch from Igor Khavkine ). * snake/snake/snake.c (main): Control -d by #ifdef DEBUG; adjust usage message accordingly. Bug reported by Malcolm Parsons . * mille/save.c (save): Handle '\r' the same as '\n'. Bug reported by Nicolas Lichtmaier . * snake/snake/snake.c (post): Always lseek back to the beginning of the file. Patch from Malcolm Parsons . * wump/wump.c (gcd): New function. (cave_init): Ensure that gcd of (delta + 1) and room_num is 1. Based on bug report and patch by . * worm/worm.c: Keep track of visible worm length. (newpos): If nowhere is available for the new prize, have the player win rather than hanging. Bug reported by Malcolm Parsons . * phantasia/Makefrag: Use a stamp file for generating score files. * phantasia/.cvsignore: Update. 2001-08-29 Joseph S. Myers * worm/worm.c (main): Check for too small a screen size. (newpos): Fix off-by-one error preventing the prize from being placed on the top line. (process): Position score appropriately for different width screens. * worm/worm.c: Whitespace tweak. * worm/worm.c, worm/worm.6: Remove documented bug with long worm lengths, and improve handling of non-standard screen sizes. From OpenBSD. * wargames/wargames: Allow - in game names. Bug reported by Guus Sliepen . * wtf/acronyms: Add AIUI. Suggestion from Adam Olsen . * phantasia/Makefrag: Fix typo. * arithmetic/arithmetic.6, atc/atc.6.in, atc/list.c, backgammon/backgammon/backgammon.6, backgammon/teachgammon/teach.c, battlestar/battlestar.6, battlestar/com2.c, battlestar/parse.c, bcd/bcd.6, boggle/boggle/boggle.6, canfield/canfield/canfield.6.in, cribbage/cribbage.6.in, factor/factor.6, fish/fish.6, fortune/datfiles/fortunes, fortune/datfiles/fortunes2, fortune/datfiles/fortunes2-o.real, fortune/datfiles/netbsd, fortune/datfiles/startrek, fortune/fortune/fortune.6.in, fortune/fortune/fortune.c, fortune/strfile/strfile.c, hack/date.h, hack/def.func_tab.h, hack/def.monst.h, hack/def.objclass.h, hack/def.objects.h, hack/def.permonst.h, hack/extern.h, hack/hack.6.in, hack/hack.Decl.c, hack/hack.apply.c, hack/hack.bones.c, hack/hack.c, hack/hack.cmd.c, hack/hack.do.c, hack/hack.do_name.c, hack/hack.dog.c, hack/hack.eat.c, hack/hack.end.c, hack/hack.engrave.c, hack/hack.fight.c, hack/hack.h, hack/hack.invent.c, hack/hack.lev.c, hack/hack.main.c, hack/hack.makemon.c, hack/hack.mhitu.c, hack/hack.mklev.c, hack/hack.mkmaze.c, hack/hack.mkobj.c, hack/hack.mkshop.c, hack/hack.mon.c, hack/hack.monst.c, hack/hack.o_init.c, hack/hack.objnam.c, hack/hack.pager.c, hack/hack.potion.c, hack/hack.pri.c, hack/hack.read.c, hack/hack.rip.c, hack/hack.save.c, hack/hack.shk.c, hack/hack.shknam.c, hack/hack.timeout.c, hack/hack.topl.c, hack/hack.trap.c, hack/hack.tty.c, hack/hack.u_init.c, hack/hack.unix.c, hack/hack.vault.c, hack/hack.wield.c , hack/hack.wizard.c, hack/hack.zap.c, hack/makedefs.c, hunt/hunt/hunt.6.in, hunt/huntd/ctl_transact.c, hunt/huntd/huntd.6.in, mille/mille.c, monop/Makefile.bsd, monop/initdeck.c, monop/monop.6.in, phantasia/Makefile.bsd, phantasia/phantasia.6, phantasia/setup.c, pom/pom.6, quiz/datfiles/collectives, quiz/datfiles/flowers, quiz/quiz.6.in, rain/rain.6, robots/robots.6.in, rogue/USD.doc/rogue.me, rogue/score.c, sail/sail.6, snake/snake/snake.6.in, tetris/tetris.6.in, trek/DOC/read_me.nr, trek/DOC/trekmanual.nr, trek/events.c, trek/main.c, trek/trek.6.in, trek/warp.c, worms/worms.6, wtf/wtf.6.in: Update from NetBSD CVS. * wtf/acronyms: Update from NetBSD CVS. * phantasia/Makefrag: Update to build generated files in source directory rather than on install. * phantasia/.cvsignore: Update. * atc/include.h, hunt/huntd/driver.c, monop/execute.c: Include . * sail/misc.c: Include . 2001-08-02 Joseph S. Myers * README, PACKAGING: Warn about inclusion of cryptographic software. 2001-03-24 Joseph S. Myers * hack/hack.cmd.c: Whitespace adjustments for NetBSD alignment. * arithmetic/arithmetic.c, banner/banner.6, fortune/datfiles/fortunes, fortune/datfiles/fortunes2-o.real, fortune/fortune/fortune.c, wtf/acronyms: Update from NetBSD CVS (but don't apply __progname changes). 2001-03-19 Joseph S. Myers * bsd-games.lsm (Primary-site), bsd-games-non-free.lsm (Primary-site): Change metalab.unc.edu to ibiblio.org. 2001-03-03 Joseph S. Myers * install-man.in, install-score.in: Use POSIX "chown user:group" instead of GNU "chown user.group". 2001-02-08 Joseph S. Myers * rogue/USD.doc/rogue.me: Fix typo (s/scroll/potion/). Reported by Lidovski Vladimir . 2001-02-07 Joseph S. Myers * adventure/hdr.h, adventure/init.c, arithmetic/arithmetic.c, atc/atc.6.in, atc/extern.h, atc/input.c, atc/log.c, atc/main.c, atc/update.c, backgammon/Makefile.bsd, backgammon/Makefile.inc.bsd, backgammon/teachgammon/teach.c, boggle/Makefile.bsd, boggle/boggle/help.c, boggle/boggle/mach.c, boggle/boggle/timer.c, boggle/boggle/word.c, cribbage/crib.c, dm/dm.c, fortune/Makefile.bsd, fortune/datfiles/Makefile.bsd, fortune/datfiles/fortunes, fortune/datfiles/fortunes-o.real, fortune/datfiles/fortunes-o.sp.ok, fortune/datfiles/fortunes2, fortune/datfiles/netbsd, fortune/fortune/fortune.c, patching file fortune/strfile/strfile.8, gomoku/bdisp.c, hack/config.h, hack/def.monst.h, hack/def.rm.h, hack/extern.h, hack/hack.6.in, hack/hack.cmd.c, hack/hack.h, hack/hack.options.c, hack/hack.read.c, hack/hack.tty.c, hack/hack.unix.c, hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/huntd/driver.c, hunt/huntd/faketalk.c, hunt/huntd/get_names.c, monop/misc.c, monop/monop.6.in, monop/prop.c, phantasia/phantglobs.h, primes/pr_tbl.c, primes/primes.c, quiz/datfiles/midearth, quiz/datfiles/pres, robots/main.c, robots/move_robs.c, robots/play_level.c, rogue/rogue.h, sail/assorted.c, sail/display.h, sail/dr_1.c, sail/dr_2.c, sail/dr_3.c, sail/dr_4.c, sail/dr_5.c, sail/dr_main.c, sail/driver.h, sail/extern.h, sail/game.c, sail/globals.c, sail/lo_main.c, sail/main.c, sail/misc.c, sail/parties.c, sail/pl_1.c, sail/pl_2.c, sail/pl_3.c, sail/pl_4.c, sail/pl_5.c, sail/pl_6.c, sail/pl_7.c, sail/pl_main.c, sail/player.h, sail/restart.h, sail/sync.c, trek/externs.c, trek/lose.c, trek/play.c, trek/win.c, wtf/wtf.in: Update from NetBSD CVS. * sail/main.c: Include . * COPYING: Update. * wtf/acronyms: Update from NetBSD CVS. 2001-01-11 Joseph S. Myers * mkdep: Update to work with current CVS GCC. * COPYING: Update copyright dates. 2000-12-20 Joseph S. Myers * rain/rain.c (main): If delay is zero, do tcdrain(STDOUT_FILENO) at the end of each iteration to avoid buffered output preventing Ctrl-C from working within a reasonable time. 2000-10-17 Joseph S. Myers * cribbage/cribbage.h: Mark msg() and addmsg() with printf format attributes. * hack/extern.h: Make vpline() with printf format attribute. * monop/misc.c (next_play): Fix undefined order of side effects. * monop/prop.c (bid): Likewise. 2000-09-25 Joseph S. Myers * Version 2.12. * NEWS, bsd-games.lsm, bsd-games-non-free.lsm: Update. * battlestar/com2.c, battlestar/com4.c, battlestar/com5.c, battlestar/cypher.c, battlestar/extern.h, battlestar/globals.c, battlestar/words.c: Update from NetBSD CVS after merge. * battlestar/extern.h: Add AUXVERB. * battlestar/words.c (wlist): Use AUXVERB for "climb", "move" and "make". * battlestar/cypher.c (cypher): Object to words in the place for a verb that aren't a VERB or KNIFE. Allow for AUXVERBs. * battlestar/com2.c (put), battlestar/com4.c (take): When creating new verbs from "put on", "put down" and "take off", make their type be VERB. Partly from Paul Janzen . * tests/battlestar.out3: Update. * tests/battlestar.in42, tests/battlestar.out42, tests/battlestar.in43, tests/battlestar.out43: New tests. * tests/battlestar.test: Update. * battlestar/extern.h: Add flags OBJ_PERSON and OBJ_NONOBJ. * battlestar/globals.c (objflags): Use them. * battlestar/extern.h: Define new macros for handling "a" versus "an" and "is" versus "are" wording issues. * battlestar/globals.c (objflags): Add OBJ_AN flags; reformat. From OpenBSD. * battlestar/com2.c (wearit, murder), battlestar/com4.c (take, eat): Use these macros. * tests/battlestar.in41, tests/battlestar.out41: New test. * tests/battlestar.test: Update. * battlestar/cypher.c (cypher): Remove excess blank lines. From OpenBSD. * battlestar/com5.c (love): Fix loving already loved goddess; avoid fallthrough after loving goddess; give error on "love amulet". From OpenBSD. * tests/battlestar.in40, tests/battlestar.out40: New test. * tests/battlestar.test: Update. * atc/atc.6.in, hack/Makefile.bsd: Update from NetBSD CVS. * battlestar/battlestar.c, battlestar/com1.c, battlestar/com2.c, battlestar/com3.c, battlestar/com4.c, battlestar/com5.c, battlestar/com6.c, battlestar/com7.c, battlestar/cypher.c, battlestar/dayfile.c, battlestar/extern.h, battlestar/fly.c, battlestar/getcom.c, battlestar/globals.c, battlestar/nightfile.c, battlestar/parse.c, battlestar/room.c, battlestar/words.c: Update from NetBSD CVS after merge. * battlestar/com3.c (jump): Use defined constant FINAL instead of hardcoded number 275. From OpenBSD. * battlestar/com2.c (murder): Fix logic of use of n and wordnumber when using laser. From OpenBSD. * tests/battlestar.in39, tests/battlestar.out39: New test. * tests/battlestar.test: Update. 2000-09-24 Joseph S. Myers * NEWS, TODO: Update. * COPYING, INSTALL, NEWS, PACKAGING, README, SECURITY: Don't use ASCII backquotes and neutral apostrophes as matched quotes. * battlestar/getcom.c (getcom): If a line of standard input goes beyond our buffer, discard extra characters rather than reading them as our next command. From OpenBSD. * battlestar/cypher.c (cypher): Improve messages when WEIGHT or CUMBER are zero. * battlestar/com2.c (ravage), battlestar/com3.c (bury), battlestar/com5.c (kiss, love, give), battlestar/com6.c (ride): Add explicit no-ops to empty loops following the NetBSD style guide. * battlestar/extern.h, battlestar/parse.c, battlestar/globals.c: Make hash table static in parse.c. * battlestar/cypher.c (cypher): For INVEN, give more sensible messages when WEIGHT or CUMBER are zero. 2000-09-23 Joseph S. Myers * battlestar/globals.c (objdes, objsht): Use NULL instead of 0; from OpenBSD. Also add or adjust comments. * battlestar/com2.c (murder), battlestar/com3.c (shoot), battlestar/com4.c (take): Correct "dont" to "don't". From OpenBSD. * tests/battlestar.out28: Update. * battlestar/parse.c: Make local functions static. * battlestar/extern.h: Remove declarations of functions now static in parse.c. * battlestar/com4.c (eat): Check first for having the object to be eaten, then for needing a knife, then for being stuffed. Also give a better message for things it doesn't make sense to eat. From OpenBSD. * tests/battlestar.in38, tests/battlestar.out38: New test. * tests/battlestar.test: Update. * battlestar/fly.c: Remove abs() macro; make local variables and functions static. * battlestar/extern.h: Remove declarations of functions now static in fly.c * battlestar/com1.c (news): Don't let CUMBER go negative. * battlestar/cypher.c (cypher): For INVEN, show -1% if CUMBER is zero. * battlestar/com4.c (drop): Disambiguate BODY; handle "kick door". From OpenBSD. * tests/battlestar.in32, tests/battlestar.out32, tests/battlestar.in33, tests/battlestar.out33, tests/battlestar.in34, tests/battlestar.out34, tests/battlestar.in35, tests/battlestar.out35, tests/battlestar.in36, tests/battlestar.out36, tests/battlestar.in37, tests/battlestar.out37: New tests. * tests/battlestar.test: Update. 2000-09-22 Joseph S. Myers * battlestar/com5.c (love): Allow for bathing goddess; better message when the lover is not present or for certain choices of lover. From OpenBSD. * battlestar/com2.c (ravage): Allow for the bathing goddess. From OpenBSD. * battlestar/extern.h: Add OBJ_PLURAL, objflags and is_plural_object. * battlestar/globals.c: Add objflags. * battlestar/com2.c (wearit), battlestar/com3.c (shoot), battlestar/com4.c (take, eat): Use is_plural_object rather than looking for a final 's'. * tests/battlestar.in31, tests/battlestar.out31: New test. * tests/battlestar.test: Update. * battlestar/com4.c (drop): When kicking, check for objects being worn or not present. From OpenBSD. * tests/battlestar.in29, tests/battlestar.out29, tests/battlestar.in30, tests/battlestar.out30: New tests. * tests/battlestar.test: Update. * battlestar/com4.c (take): Check for the object not being present before checking for it being too heavy or bulky. * tests/battlestar.in28, tests/battlestar.out28: New test. * tests/battlestar.test: Update. 2000-09-21 Joseph S. Myers * battlestar/cypher.c (cypher): Give appropriate messages for verbs applied to "all" where nothing relevant is present. From OpenBSD. * tests/battlestar.in27, tests/battlestar.out27: New test. * tests/battlestar.test: Update. * battlestar/com2.c (wearit, use, murder), battlestar/com3.c (shoot), battlestar/com4.c (take, throw, drop, eat), battlestar/com6.c (dooropen), battlestar/cypher.c (cypher), battlestar/parse.c (parse): Move all discarding of adjectives to parse(). From Paul Janzen . Fixes crash on "carry old all", shown up by fuzz testing. * tests/battlestar.in26, tests/battlestar.out26: New test. * tests/battlestar.test: Update. * battlestar/com2.c (murder): Give error rather than crashing on "kill all". From OpenBSD. * tests/battlestar.in25, tests/battlestar.out25: New test. * tests/battlestar.test: Update. * battlestar/extern.h: Define and use WORDLEN. From OpenBSD. * battlestar/globals.c: Also use WORDLEN. From OpenBSD. * battlestar/battlestar.c (main): Use NWORD rather than 20 (from OpenBSD). Avoid off-by-one error by using NWORD - 1. * battlestar/cypher.c (cypher): Increment wordnumber after INVEN. * battlestar/getcom.c (getword): Avoid overflowing elements of the words array. From OpenBSD. * battlestar/words.c (wlist): Parse "," as AND. From OpenBSD. * battlestar/parse.c (parse): Trim AND AND. When an OBJECT AND EVERYTHING or NOUNS AND EVERYTHING sequence occurs, move the EVERYTHING to the beginning. Trim EVERYTHING AND EVERYTHING. From OpenBSD. Also disable parsing of "," as AND if followed by a verb. * tests/battlestar.in21, tests/battlestar.out21, tests/battlestar.in22, tests/battlestar.out22, tests/battlestar.in23, tests/battlestar.out23, tests/battlestar.in24, tests/battlestar.out24: New tests. * tests/battlestar.test: Update. * battlestar/com2.c (wearit): Don't attempt to wear anything with no short description. * tests/battlestar.in20, tests/battlestar.out20: New tests. * tests/battlestar.test: Update. * battlestar/com2.c (wearit): Partly from OpenBSD: don't try to wear anything that isn't OBJECT or NOUNS, and don't try to wear DOOR. Fixes with a different patch a bug report from Peter Maydell . * tests/battlestar.in16, tests/battlestar.out16, tests/battlestar.in17, tests/battlestar.out17, tests/battlestar.in18, tests/battlestar.out18, tests/battlestar.in19, tests/battlestar.out19: New tests. * tests/battlestar.test: Update. * battlestar/com2.c (murder): From OpenBSD: shoot with laser if no hand-to-hand weapon available. 2000-09-20 Joseph S. Myers * battlestar/getcom.c (getcom): die() on EOF; based on OpenBSD. * tests/battlestar.out15: New test. * tests/battlestar.test: Update. * battlestar/com6.c (open_score_file): If BATTLESTAR_QUIET is set in the environment, don't give a warning. * tests/battlestar.test: Set BATTLESTAR_QUIET so tests can be done as a user without write access to the log file. * battlestar/com5.c (kiss): From OpenBSD, "take" the bathing goddess if required; give a better message when trying to kiss a person who is not present. * tests/battlestar.in14, tests/battlestar.out14: New tests. * tests/battlestar.test: Update. 2000-09-17 Joseph S. Myers * battlestar/dayfile.c (dayfile), battlestar/nightfile.c (nightfile): Add missing initialisers and comments giving room numbers. * wtf/acronyms: Update from NetBSD CVS. * battlestar/com1.c, battlestar/com2.c, battlestar/com4.c, battlestar/com5.c, battlestar/com6.c, battlestar/com7.c, battlestar/getcom.c: Clean up formatting; partly from OpenBSD. * tests/battlestar.in9, tests/battlestar.out9, tests/battlestar.in10, tests/battlestar.out10, tests/battlestar.in11, tests/battlestar.out11, tests/battlestar.in12, tests/battlestar.out12, tests/battlestar.in13, tests/battlestar.out13: New tests. * tests/battlestar.test: Update. * battlestar/com6.c (dooropen): New function, from OpenBSD. * battlestar/cypher.c (cypher): Support new verbs OPEN, VERBOSE and BRIEF, from OpenBSD. * battlestar/extern.h: Add new verbs OPEN, VERBOSE and BRIEF, new variable verbose, and new function dooropen(), from OpenBSD. * battlestar/globals.c (verbose): New variable, from OpenBSD. * battlestar/room.c (writedes): If verbose, always give long description; from OpenBSD. * battlestar/words.c (wlist): Add synonyms "papaya" and "coconut" and verbs "open", "unlock", "verbose" and "brief", from OpenBSD. 2000-09-10 Joseph S. Myers * battlestar/com2.c, battlestar/com3.c, battlestar/com4.c, battlestar/com5.c, battlestar/com6.c, battlestar/com7.c, battlestar/cypher.c, battlestar/dayfile.c, battlestar/nightfile.c, battlestar/room.c, battlestar/words.c: Update from NetBSD CVS after merge. 2000-09-09 Joseph S. Myers * battlestar/room.c (writedes): Process '=' in descriptions as meaning a literal '-'; from OpenBSD. * battlestar/dayfile.c (dayfile), battlestar/nightfile.c (nightfile): Spelling, punctuation and line length adjustments from OpenBSD. * tests/battlestar.out4, tests/battlestar.out5, tests/battlestar.out8: Update for changes in line length. * battlestar/com2.c (murder): Give an appropriate message for trying to kill non-OBJECT things (from OpenBSD); fixes "kill door" segfault. * battlestar/com3.c (shoot), battlestar/com4.c (take), battlestar/com5.c (kiss), battlestar/com6.c (ride), battlestar/com7.c (fight), battlestar/cypher.c (save): Wording, spelling, punctuation and line length adjustments from OpenBSD. * tests/battlestar.out5, tests/battlestar.out6: Update for changed wording. * tests/battlestar.in8, tests/battlestar.out8: New tests. * tests/battlestar.test: Update. * battlestar/words.c: Make spacing nicer and add missing initialisers. * NEWS, TODO: Update. * battlestar/battlestar.6, battlestar/battlestar.c, battlestar/com1.c, battlestar/com5.c, battlestar/cypher.c, battlestar/dayfile.c, battlestar/extern.h, battlestar/globals.c, battlestar/init.c, battlestar/nightfile.c, battlestar/room.c: Update from NetBSD CVS after merge. 2000-09-08 Joseph S. Myers * battlestar/battlestar.6: Don't refer to ~. Suggested by Hubert Feyrer. * battlestar/extern.h, battlestar/globals.c, battlestar/init.c: Don't restrict length of username, use a string from strdup instead. Make functions and arrays only used in init.c static. 2000-09-07 Joseph S. Myers * battlestar/extern.h: Put prototypes in alphabetical order. * fortune/datfiles/Makefile.bsd: Really update from NetBSD CVS. * battlestar/battlestar.6: Improvements from OpenBSD. * battlestar/extern.h: Define ROOMDESC. * battlestar/room.c (writedes): Use it. * battlestar/battlestar.c: From OpenBSD, make clearer and don't increase beenthere[position] beyond ROOMDESC. * battlestar/com1.c (news), battlestar/com5.c (kiss), battlestar/cypher.c (cypher), battlestar/dayfile.c (dayfile), battlestar/globals.c (objdes, objsht), nightfile.c (nightfile): Spelling and punctuation corrections or adjustments from OpenBSD. * tests/battlestar.test: Test for wizard or anti-wizard users. 2000-09-06 Joseph S. Myers * tests/battlestar.in5, tests/battlestar.out5, tests/battlestar.in6, tests/battlestar.out6, tests/battlestar.err6: New files. * tests/battlestar.test: Update. * tests/battlestar.test, tests/battlestar.in1, tests/battlestar.out1, tests/battlestar.in2, tests/battlestar.out2, tests/battlestar.in3, tests/battlestar.out3, tests/battlestar.in4, tests/battlestar.out4: New files. * lib/.cvsignore: New file. * morse/.cvsignore: Add morse. 2000-08-22 Joseph S. Myers * hunt/hunt/.cvsignore, hunt/huntd/.cvsignore, mille/.cvsignore, monop/.cvsignore, morse/.cvsignore, number/.cvsignore, phantasia/.cvsignore, pig/.cvsignore, pom/.cvsignore, ppt/.cvsignore, primes/.cvsignore, quiz/.cvsignore, quiz/datfiles/.cvsignore, rain/.cvsignore, random/.cvsignore, robots/.cvsignore, rogue/.cvsignore, sail/.cvsignore, snake/snake/.cvsignore, snake/snscore/.cvsignore, tetris/.cvsignore, trek/.cvsignore, worm/.cvsignore, worms/.cvsignore, wtf/.cvsignore, wump/.cvsignore: New files. 2000-08-19 Joseph S. Myers * fortune/datfiles/.cvsignore, fortune/fortune/.cvsignore, fortune/strfile/.cvsignore, fortune/unstr/.cvsignore, gomoku/.cvsignore, hack/.cvsignore, hangman/.cvsignore: New files. 2000-08-18 Joseph S. Myers * caesar/.cvsignore, canfield/canfield/.cvsignore, canfield/cfscores/.cvsignore, cribbage/.cvsignore, dm/.cvsignore, factor/.cvsignore, fish/.cvsignore: New files. * fortune/datfiles/Makefile.bsd, fortune/datfiles/fortunes, fortune/datfiles/netbsd, fortune/datfiles/netbsd-o.fake, fortune/datfiles/netbsd-o.real, wtf/acronyms: Update from NetBSD CVS. 2000-08-05 Joseph S. Myers * .cvsignore, include/.cvsignore, adventure/.cvsignore, arithmetic/.cvsignore, atc/.cvsignore, backgammon/backgammon/.cvsignore, backgammon/common_source/.cvsignore, backgammon/teachgammon/.cvsignore, banner/.cvsignore, battlestar/.cvsignore, bcd/.cvsignore, boggle/boggle/.cvsignore, boggle/mkdict/.cvsignore, boggle/mkindex/.cvsignore: New files. * wtf/acronyms: Update from NetBSD CVS. 2000-08-04 Joseph S. Myers * include/signal.h, include/stdio.h, include/stdlib.h, include/termios.h, include/sys/cdefs.h, include/sys/ttydefaults.h: Use #pragma GCC system_header to allow #include_next with -pedantic. 2000-08-03 Joseph S. Myers * atc/input.c, atc/log.c, atc/update.c, hack/config.h, hack/def.monst.h, hack/def.rm.h, hack/hack.cmd.c, hack/hack.h, robots/move_robs.c, robots/play_level.c: Comment out text after #endif. * bcd/bcd.c: Use unsigned char and casts to avoid -pedantic warnings. * pom/pom.c: Likewise. * fortune/unstr/unstr.c, hack/makedefs.c: Include . * lib/fgetln.c: Include . * adventure/setup.c, battlestar/com1.c, battlestar/com7.c, battlestar/cypher.c, battlestar/extern.h, boggle/mkdict/mkdict.c, boggle/mkindex/mkindex.c, fortune/datfiles/netbsd, fortune/strfile/strfile.c, hack/makedefs.c, monop/initdeck.c: Update from NetBSD CVS. 2000-08-02 Joseph S. Myers * sail/extern.h (abs): Don't define; breaks with glibc 2.2. 2000-07-22 Joseph S. Myers * hack/hack.tty.c, monop/getinp.c, rogue/message.c, trek/phaser.c: Update from NetBSD CVS. 2000-07-06 Joseph S. Myers * adventure/done.c, adventure/main.c, adventure/subr.c, bcd/bcd.c, canfield/cfscores/cfscores.c, countmail/countmail.6, fortune/datfiles/fortunes, fortune/datfiles/fortunes2, fortune/datfiles/netbsd, gomoku/stoc.c, hack/hack.h, hunt/huntd/get_names.c, morse/morse.c, phantasia/Makefile.bsd, ppt/ppt.c, rogue/init.c, sail/Makefile.bsd, sail/lo_main.c, sail/pl_1.c, sail/pl_7.c, trek/computer.c, trek/destruct.c, trek/getpar.c, trek/setup.c, trek/torped.c: Update from NetBSD CVS. 2000-05-28 Joseph S. Myers * adventure/Makefile.bsd, adventure/main.c, arithmetic/arithmetic.c, atc/main.c, backgammon/backgammon/main.c, backgammon/teachgammon/teach.c, battlestar/battlestar.c, bcd/bcd.c, boggle/boggle/bog.c, caesar/caesar.c, caesar/rot13.in, canfield/canfield/canfield.c, canfield/cfscores/cfscores.c, cribbage/crib.c, fish/fish.c, fortune/datfiles/netbsd, gomoku/main.c, hack/hack.termcap.c, hangman/main.c, mille/mille.c, mille/misc.c, mille/print.c, monop/cards.inp, monop/monop.c, morse/morse.c, phantasia/Makefile.bsd, phantasia/fight.c, phantasia/misc.c, ppt/ppt.c, quiz/quiz.c, robots/main.c, robots/score.c, snake/snake/snake.c, snake/snscore/snscore.c, tetris/screen.c, tetris/screen.h, trek/main.c, worm/worm.c, wump/wump.c: Update from NetBSD CVS. 2000-05-27 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 2000-05-06 Joseph S. Myers * bsd-games now under CVS version control. At present there is no anoncvs access, so this isn't particularly relevant to anyone else yet. The CVS tree up to now has been generated with scripts based on RCS to include all past releases and betas from 1.3 onwards, and those snapshots of the bsd-games source tree from in between releases that I have, with checkin dates set to the dates of the ChangeLogs in the respective releases and snapshots. Tags used are BSD_GAMES_DATE_yyyy_mm_dd for dated snapshots; BSD_GAMES_v_v for versioned bsd-games releases; BSD_GAMES_NON_FREE_v_v for bsd-games-non-free releases; and BSD_GAMES_VERSION_v_v for the union of corresponding bsd-games and bsd-games-non-free releases, and for bsd-games releases before the split, but this tag was not applied where no bsd-games-non-free release corresponded to a particular bsd-games release. 2000-04-26 Joseph S. Myers * bsd-games.lsm, bsd-games-non-free.lsm: Update to LSM format version 4. 2000-04-19 Joseph S. Myers * Version 2.11. * NEWS: Update. * bsd-games.lsm: Update. * bsd-games-non-free.lsm: Update. * hack/date.h, hack/def.monst.h, hack/def.objclass.h, hack/def.objects.h, hack/def.permonst.h, hack/extern.h, hack/hack.Decl.c, hack/hack.cmd.c, hack/hack.dog.c, hack/hack.eat.c, hack/hack.end.c, hack/hack.engrave.c, hack/hack.fight.c, hack/hack.h, hack/hack.invent.c, hack/hack.lev.c, hack/hack.main.c, hack/hack.makemon.c, hack/hack.mhitu.c, hack/hack.mklev.c, hack/hack.mkmaze.c, hack/hack.mkobj.c, hack/hack.mkshop.c, hack/hack.mon.c, hack/hack.monst.c, hack/hack.o_init.c, hack/hack.objnam.c, hack/hack.pager.c, hack/hack.pri.c, hack/hack.read.c, hack/hack.rip.c, hack/hack.save.c, hack/hack.shk.c, hack/hack.termcap.c, hack/hack.timeout.c, hack/hack.topl.c, hack/hack.tty.c, hack/hack.u_init.c, hack/hack.unix.c, hack/hack.vault.c, hack/hack.wield.c, hack/hack.wizard.c, hack/hack.zap.c: Use const and fix compiler warnings. 2000-04-18 Joseph S. Myers * hack/*: New, from NetBSD CVS. * hack/Makefile: Rename to Makefile.bsd. * AUTHORS, COPYING, INSTALL, README, README.non-free, SECURITY, TODO: Update. * NEWS: Update. * bsd-games-non-free.lsm: Update. * hack/pathnames.h: Rename to pathnames.h.in for substitutions. * hack/hack.6: Rename to hack.6.in for substitutions. * configure, substfiles, substfiles2, Makeconfig.in: Update. * exec.libs, exec.objs: Update. * hack/Makefrag: New file. * hack/hack.main.c: Check for fds 0, 1, 2 being closed; use setregid() for gid revokes. * hack/hack.bones.c, hack/hack.do.c, hacl/hack.main.c, hack/hack.pager.c, hack/hack.save.c, hack/hack.unix.c, hack/makedefs.c: Use symbolic constants. * hack/makedefs.c: Check for write errors on output; use const and fix compiler warnings. * hack/def.func_tab.h, hack/def.objclass.h, hack/def.permonst.h, hack/extern.h, hack/hack.Decl.c, hack/hack.apply.c, hack/hack.c, hack/hack.cmd.c, hack/hack.do_name.c, hack/hack.end.c, hack/hack.invent.c, hack/hack.h, hack/hack.main.c, hack/hack.mon.c, hack/hack.objnam.c, hack.pager.c, hack.potion.c, hack/hack.shknam.c, hack.trap.c, hack.zap.c: Use const and fix compiler warnings. 2000-04-15 Joseph S. Myers * arithmetic/arithmetic.c, boggle/mkdict/Makefile.bsd, boggle/mkindex/Makefile.bsd, fortune/datfiles/fortunes, fortune/datfiles/fortunes2, fortune/fortune/fortune.c, fortune/strfile/Makefile.bsd, hunt/Makefile.inc.bsd, hunt/hunt/hunt.c, hunt/huntd/driver.c, phantasia/fight.c, robots/score.c: Update from NetBSD CVS. 2000-04-14 Joseph S. Myers * COPYING: Fix spelling error. 2000-04-09 Joseph S. Myers * quiz/datfiles/asia: Corrections from Robert Vollmert . 2000-04-05 Joseph S. Myers * countmail/countmail.6: Fix grammar (bug reported by Thomas Bushnell BSG ). 2000-03-29 Joseph S. Myers * boggle/boggle/prtable.c, fish/fish.c, fortune/datfiles/fortunes, fortune/datfiles/fortunes2, fortune/datfiles/fortunes2-o.real, fortune/datfiles/netbsd, gomoku/makemove.c, hunt/hunt/hunt.c, rogue/CHANGES, trek/trek.6.in: Update from NetBSD CVS. 2000-02-28 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 2000-02-12 Joseph S. Myers * Version 2.10. * fortune/fortune/fortune.c: Include . * fortune/unstr/unstr.c: Likewise. * fortune/strfile/strfile.c: Include . * monop/initdeck.c: Likewise. Remove unnecessary casts. * NEWS: Update. * bsd-games.lsm: Update. * fortune/datfiles/netbsd, sail/Makefile.bsd: Update from NetBSD CVS. * COPYING: Add 2000 to copyright years. * wtf/acronyms: Update from NetBSD CVS. 2000-02-09 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. * THANKS: Update. * INSTALL: Update. * Essentially all relevant changes now merged back into NetBSD (except for hunt). * TODO: Update. * NEWS: Update. * sail/Makefile.bsd, sail/dr_main.c, sail/extern.h, sail/globals.c, sail/main.c, sail/misc.c, sail/pathnames.h.in, sail/pl_7.c, sail/pl_main.c, sail/sync.c: Update from NetBSD CVS after further merge. * fortune/datfiles/Makefile.bsd, wargames/Makefile.bsd: Update from NetBSD CVS. * fortune/datfiles/netbsd: New, from NetBSD. 2000-02-01 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 2000-01-24 Joseph S. Myers * snake/snscore/snscore.c, tetris/scores.c, tetris/tetris.c, wargames/Makefile.bsd, wargames/wargames.6: Update from NetBSD CVS after further merge. * boggle/Makefile.bsd, fortune/Makefile.bsd, fortune/datfiles/Makefile.bsd, hunt/hunt/hunt.c, hunt/huntd/hunt.h, phantasia/Makefile.bsd: Update from NetBSD CVS. 2000-01-20 Joseph S. Myers * robots/main.c, robots/score.c: Update from NetBSD CVS after further merge. 2000-01-19 Joseph S. Myers * fortune/strfile/strfile.c, random/random.c: Update from NetBSD CVS after further merge. 2000-01-17 Joseph S. Myers * random/random.c: Define MAXRANDOM rather than using RAND_MAX. 2000-01-13 Joseph S. Myers * adventure/io.c, adventure/vocab.c, battlestar/save.c, caesar/caesar.c, monop/monop.c, worm/worm.c: Update from NetBSD CVS after further merge. 2000-01-08 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 2000-01-02 Joseph S. Myers * tetris/screen.h, tetris/tetris.c, tetris/tetris.h: Update from NetBSD CVS after further merge. 1999-12-31 Joseph S. Myers * fortune/strfile/strfile.c, fortune/strfile/strfile.h, monop/cards.c, monop/initdeck.c: Update from NetBSD CVS. 1999-12-28 Joseph S. Myers * sail/extern.h, sail/globals.c, sail/pl_7.c, sail/player.h: Update from NetBSD CVS after further merge. 1999-12-16 Joseph S. Myers * ppt/ppt.c, quiz/quiz.c: Update from NetBSD CVS (more changes merged into NetBSD). * quiz/quiz.c (show_index): Refer error message to the pager actually used. * fortune/strfile/strfile.c: Use err(1, NULL) for out-of-memory error. * boggle/mkindex/mkindex.c, fortune/datfiles/fortunes, fortune/strfile/strfile.c, wargames/wargames, wtf/wtf.in: Update from NetBSD CVS. 1999-12-07 Joseph S. Myers * adventure/io.c, adventure/vocab.c, battlestar/save.c, caesar/caesar.c, monop/cards.c, monop/initdeck.c, monop/monop.c, monop/prop.c, snake/snscore/snscore.c, worm/worm.c: Use err(1, NULL) or warn(NULL) for `out of memory' messages. * fortune/strfile/strfile.c: Remove obsolete NO_VOID conditional, and casts in ALLOC macro. 1999-12-06 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 1999-11-29 Joseph S. Myers * ChangeLog: Use consistent form of my name and email address. 1999-11-15 Joseph S. Myers * countmail/countmail: Don't describe messages as new when they may not be (bug report and suggested fix from Malcolm Parsons ). * configure: Ask for permissions on variable data that should not be world readable (bug report from ). * install-score.in: Use this. * phantasia/Makefrag: Use this. * SECURITY: Update. * tetris/tetris.c: Include ; use errx() for error messages; change usage message to refer to tetris-bsd (bug report from Malcolm Parson ). * tetris/scores.c (printem): Fix formatting of high score tables with multiple columns (bug report and suggested fix from Malcolm Parsons ). * robots/main.c (main): Fix spelling error in unknown option message (bug report and suggested fix by Malcolm Parsons ). 1999-11-12 Joseph S. Myers * Version 2.9. * bsd-games.lsm: Update. * NEWS: Update. 1999-11-11 Joseph S. Myers * boggle/mkindex/mkindex.c (main): Add index entries for letters not found in the dictionary (problem reported by Mike Castle ). * robots/main.c (main): Reinitialise Num_games to 1 after looping through Num_games games, so if you ask for another game then you still get this prompt next time. Bug report and suggested fix from Malcolm Parsons . * robots/score.c (score): Fix reporting of auto-bot scores, bug report and suggested fix from Malcolm Parsons . * cribbage/instr.c, fortune/fortune/fortune.c, snake/snake/snake.6.in, snake/snake/snake.c, worm/worm.6, worm/worm.c: Update from NetBSD CVS. 1999-11-05 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 1999-10-28 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. * random/random.c: Use RAND_MAX rather than LONG_MAX (patch from William Brioschi). * tests/rot13.*: Removed; test not meaningful since it uses the installed caesar (which may not be present) rather than the just-built one. Bug reported by Roman Hodek . 1999-10-21 Joseph S. Myers * backgammon/common_source/back.h, backgammon/common_source/subs.c, robots/main.c, tetris/screen.c, tetris/screen.h: Update from NetBSD CVS. 1999-10-11 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. 1999-10-01 Joseph S. Myers * cribbage/cribbage.6.in, mille/move.c: Update from NetBSD CVS after further merge. 1999-09-30 Joseph S. Myers * atc/def.h, cribbage/cards.c, cribbage/cribbage.h, cribbage/io.c, mille/comp.c, mille/init.c, mille/mille.h, mille/move.c, mille/types.h, monop/misc.c, monop/monop.h, monop/trade.c, phantasia/phantdefs.h, robots/robots.h, sail/dr_1.c, sail/dr_2.c, sail/dr_3.c, sail/extern.h: Update from NetBSD CVS after further merge. * cribbage/cribbage.6.in (FILES): Tweak. 1999-09-27 Joseph S. Myers * quiz/datfiles/europe (Monaco): Change capital to Monaco, bug reported by . 1999-09-26 Joseph S. Myers * Version 2.8. * include/tzfile.h: Remove (no longer used). * fortune/datfiles/Makefrag: Use $(SHAREDIR) not $(LIBDIR). * NEWS: Update. * bsd-games.lsm, bsd-games-non-free.lsm: Update. * */Makefrag, */*/Makefrag: Add copyright notices and licence terms. * hangman/Makefrag: Remove reference to $(hangman_WORDS). * COPYING: Tweak. * NEWS: Add release dates. 1999-09-23 Joseph S. Myers * dm/dm.c, fish/fish.c, fortune/fortune/fortune.c: Update from NetBSD CVS after further merge. * fortune/datfiles/Makefile.bsd: Update from NetBSD CVS. 1999-09-19 Joseph S. Myers * boggle/boggle/bog.c, boggle/mkdict/mkdict.c, cribbage/extern.c, dm/dm.c, phantasia/setup.c: Update from NetBSD CVS after further merge. 1999-09-18 Joseph S. Myers * boggle/mkdict/mkdict.c, boggle/mkindex/mkindex.c: Update from NetBSD CVS after further merge. * battlestar/com1.c, battlestar/com4.c: Tweak for NetBSD alignment. * battlestar/com1.c, battlestar/com4.c, boggle/boggle/bog.c, cribbage/io.c, fortune/fortune/fortune.c, fortune/strfile/strfile.c, fortune/unstr/unstr.c, gomoku/pickmove.c, mille/comp.c, phantasia/interplayer.c, pig/pig.c, robots/extern.c, robots/robots.h, robots/score.c, rogue/save.c, tetris/scores.c, trek/main.c: Update from NetBSD CVS after further merge. * battlestar/battlestar.c, battlestar/cypher.c, battlestar/dayobjs.c, battlestar/init.c, battlestar/nightobjs.c: Update from NetBSD CVS after further merge. * backgammon/backgammon/main.c, boggle/boggle/bog.c, hangman/extern.c, hangman/hangman.6.in, hangman/hangman.h, hangman/main.c, hangman/setup.c, quiz/quiz.c, sail/game.c, tetris/scores.c, trek/externs.c, trek/trek.h: Update from NetBSD CVS after further merge. 1999-09-17 Joseph S. Myers * wtf/acronyms: Update from NetBSD CVS. * NEWS: Update. * hangman/extern.c, hangman/hangman.h, hangman/main.c, hangman/setup.c: Make dictionary path selectable at run time. * hangman/hangman.6.in: Document this. * NEWS, TODO, INSTALL, PACKAGING: Update. 1999-09-16 Joseph S. Myers * hangman/words: Remove. The copyright status was not clear; assertions in the LSM entry that it is free from copyright seem to be contradicted by inspection of the READMEs. (See ftp://ftp.cs.unc.edu/pub/users/faith/linux/utils/ .) * hangman/Makefrag: No longer install words file. * configure: Update accordingly. * boggle/mkdict/Makefrag: Update accordingly. * Makeconfig.in: Update accordingly. * NEWS: Update. * INSTALL: Update. * PACKAGING: Update. * configure: Fix bugs in earlier changes. * sail/game.c (maxturns): Tweak following comments from Hubert Feyrer. * boggle/boggle/bog.c (checkdict): Tweak following comments from Hubert Feyrer. * trek/trek.h: Modify form of structure/variable declarations (following comments from Hubert Feyrer). * battlestar/battlestar.c (main): Give a sensible error message in the default (should't happen) case. 1999-09-15 Joseph S. Myers * COPYING: Update. * substfiles: Move manpages and some other non-headers into substfiles2 (new file). * quiz/datfiles/Makefrag (quiz_datfiles_all): Depend on quiz/datfiles/index. * configure: Only generate rules for files in substfiles2, don't actually build them at configure time. * TODO: Update. * configure: Allow for comments in exec.objs, exec.libs and substfiles. * exec.objs, exec.libs, substfiles: Add explanatory comments, copyright notices and licence terms. * substscr: New file to handle substitution logic. Also generate subst.rules makefile for redoing the substitutions if required. * configure: Use it to do substitutions. Handle subst.rules. * fortune/unstr/unstr.c: Don't include at all. * gomoku/pickmove.c: Likewise, unconditionally include rather than . * fortune/fortune/fortune.c: Use macro NAMLEN rather than strlen(dirent->d_name). 1999-09-14 Joseph S. Myers * gomoku/main.c: Tweak for NetBSD alignment. * battlestar/com6.c, battlestar/extern.h, battlestar/globals.c, pom/pom.6, pom/pom.c, snake/snake/Makefile.bsd, snake/snake/snake.6.in, snake/snake/snake.c: Update from NetBSD CVS after further merge. * fortune/fortune/fortune.c: Adjust (unsigned long) casts to use (u_int32_t) and (u_int64_t) as appropriate. * TODO: Update. * phantasia/setup.c: Add checks for write errors. * fortune/fortune/fortune.6.in, fortune/fortune/pathnames.h.in: Fix references to @usrlibdir@. * quiz/datfiles/pres: Update to OpenBSD version (minor corrections, and includes vice-presidents). * quiz/datfiles/index.in: Update. 1999-09-13 Joseph S. Myers * battlestar/com6.c, battlestar/extern.h, battlestar/init.c, cribbage/instr.c, gomoku/gomoku.h, gomoku/main.c, phantasia/main.c, rogue/Makefile.bsd, rogue/machdep.c, rogue/rogue.h, rogue/save.c: Update from NetBSD CVS after further merge. * fortune/datfiles/Makefile.bsd, fortune/datfiles/limerick, fortune/datfiles/limerick-o.fake, fortune/datfiles/limerick-o.real, fortune/datfiles/limerick.fake, fortune/datfiles/limerick.real, fortune/datfiles/unamerican-o.fake, fortune/datfiles/unamerican-o.real, fortune/datfiles/unamerican.fake, fortune/datfiles/unamerican.real: Update from NetBSD CVS (offensive fortunes renamed to ...-o). * fortune/datfiles/Makefrag: Update. * tests/*: Add testsuite. * configure: Update. * bcd/Makefrag, caesar/Makefrag, factor/Makefrag, morse/Makefrag, number/Makefrag, pig/Makefrag, pom/Makefrag, ppt/Makefrag, primes/Makefrag, wargames/Makefrag: Remove old test fragments. * COPYING: Update. * INSTALL: Update. * NEWS: Update. * lib/fgetln.c, lib/getloadavg.c: Add copyright notice and licence terms. * include/signal.h, include/stdio.h, include/stdlib.h, include/termios.h, include/tzfile.h, include/sys/cdefs.h, include/sys/endian.h, include/sys/ttydefaults.h: Likewise. * hide-game.in, install-man.in, install-score.in, mkdep: Likewise. * configure, Makeconfig.in: Likewise. * COPYING: Update. 1999-09-12 Joseph S. Myers * wargames/wargames.6: Add copyright notice and licence terms; convert to use tmac.doc. * COPYING: Update. * snake/snake/snake.6.in: Fix substitution. * snake/snake/snake.c: #ifdef keypad functionality so snake can be built/tested on systems without it. * AUTHORS: Fix entries for rogue and worm. * canfield/canfield/canfield.c, canfield/cfscores/cfscores.c, cribbage/crib.c, fish/fish.c, gomoku/main.c, hangman/main.c, mille/mille.c, monop/monop.c, morse/morse.c, ppt/ppt.c, quiz/quiz.c, robots/main.c, robots/robots.h, robots/score.c, rogue/init.c, rogue/machdep.c, rogue/rogue.h, rogue/score.c, snake/snake/snake.c, snake/snscore/snscore.c, tetris/scores.c, tetris/tetris.c, tetris/tetris.h, trek/main.c, worm/worm.c, wump/wump.c: Update from NetBSD CVS after merge of most security changes. 1999-09-11 Joseph S. Myers * wtf/acronyms: Updatef from NetBSD-current. * COPYING: New file. * NEWS: Update. * README: Update. 1999-09-10 Joseph S. Myers * wump/wump.c: Update from NetBSD CVS. * rogue/curses.c: Remove. * rogue/machdep.c, rogue/rogue.h: Remove traces of CURSES. * THANKS: Update. * NEWS: Update. * gomoku/main.c (main): Comment tweak. * rogue/init.c: Add blank line. * robots/main.c (main): Restore errno before printing error message. * robots/query.c: NetBSD alignment tweak. * atc/graphics.c, boggle/mkdict/mkdict.c, boggle/mkindex/mkindex.c, cribbage/cribbage.h, fortune/strfile/strfile.c, monop/initdeck.c: Update from NetBSD CVS after further merge. 1999-09-09 Joseph S. Myers * monop/initdeck.c (main): Whitespace tweaks. * backgammon/backgammon/main.c, boggle/boggle/extern.h, canfield/canfield/canfield.c, fortune/fortune/fortune.c, fortune/strfile/strfile.c, gomoku/pickmove.c, hangman/setup.c, mille/save.c, monop/cards.c, monop/initdeck.c, monop/monop.c, monop/monop.h, monop/prop.c, rogue/init.c, sail/sync.c, snake/snscore/snscore.c, worm/worm.c, wump/wump.c: Update from NetBSD CVS after merge of malloc checks and includes. * fortune/strfile/strfile.8: Update from NetBSD CVS. * mille/save.c: Move include up. * backgammon/backgammon/main.c: Move include up. Use NULL as argument of time() instead of 0. * backgammon/common_source/subs.c, battlestar/com6.c, battlestar/fly.c, boggle/boggle/bog.c, boggle/boggle/extern.h, boggle/boggle/mach.c, boggle/boggle/prtable.c, boggle/boggle/word.c, caesar/caesar.c, canfield/canfield/canfield.c, canfield/cfscores/cfscores.c, cribbage/cards.c, cribbage/crib.c, cribbage/cribbage.h, cribbage/io.c, cribbage/score.c, cribbage/support.c, factor/factor.c, fish/fish.c, fortune/fortune/fortune.c, fortune/strfile/strfile.c, fortune/unstr/unstr.c, gomoku/bdisp.c, gomoku/gomoku.h, gomoku/main.c, gomoku/makemove.c, gomoku/pickmove.c, gomoku/stoc.c, hangman/extern.c, hangman/getword.c, hangman/hangman.h, hangman/main.c, hangman/setup.c, mille/comp.c, mille/extern.c, mille/mille.c, mille/mille.h, mille/move.c, mille/print.c, mille/save.c, monop/cards.c, monop/execute.c, monop/getinp.c, monop/houses.c, monop/initdeck.c, monop/misc.c, monop/monop.c, monop/monop.def, monop/monop.ext, monop/monop.h, monop/morg.c, monop/print.c, monop/spec.c, monop/trade.c, morse/morse.c, number/number.c, phantasia/fight.c, phantasia/gamesupport.c, phantasia/interplayer.c, phantasia/io.c, phantasia/main.c, phantasia/misc.c, phantasia/phantglobs.c, phantasia/phantglobs.h, phantasia/phantstruct.h, phantasia/setup.c, primes/pattern.c, primes/pr_tbl.c, primes/primes.c, quiz/quiz.c, quiz/quiz.h, quiz/rxp.c, random/random.c, robots/auto.c, robots/extern.c, robots/init_field.c, robots/main.c, robots/move.c, robots/query.c, robots/robots.h, robots/score.c, rogue/init.c, rogue/rogue.h, sail/assorted.c, sail/dr_1.c, sail/dr_2.c, sail/driver.h, sail/extern.h, sail/globals.c, sail/lo_main.c, sail/pl_1.c, sail/pl_3.c, sail/pl_4.c, sail/pl_7.c, sail/sync.c, snake/snake/snake.c, snake/snscore/snscore.c, tetris/scores.c, tetris/screen.c, tetris/shapes.c, tetris/tetris.c, tetris/tetris.h, trek/abandon.c, trek/capture.c, trek/cgetc.c, trek/computer.c, trek/dcrept.c, trek/destruct.c, trek/dock.c, trek/dumpgame.c, trek/getpar.h, trek/help.c, trek/impulse.c, trek/lrscan.c, trek/phaser.c, trek/play.c, trek/rest.c, trek/setwarp.c, trek/torped.c, trek/trek.h, trek/visual.c, worm/worm.c: Update from NetBSD CVS after initial merge of const, attribute and symbolic constant changes. 1999-09-08 Joseph S. Myers * README: Update. * NEWS: Update. 1999-08-29 Joseph S. Myers * INSTALL: Update. 1999-08-22 Joseph S. Myers * README: Update. * NEWS: Update. * TODO: Update. * include/sys/endian.h: Add the 16-bit functions in case they get used in the games later. Still does not include the little-endian functions until some game starts using data in little-endian format. * AUTHORS: Update. * BUGS: Update. 1999-08-21 Joseph S. Myers * include/sys/endian.h: New file (compatibility with changes in NetBSD). * fortune/fortune/fortune.c, fortune/strfile/strfile.8, fortune/strfile/strfile.c, fortune/strfile/strfile.h, fortune/fortune/unstr.c: Update from NetBSD anoncvs. * fortune/datfiles/Makefrag: fortune data is now arch-independent. * phantasia/Makefile.bsd, phantasia/main.c: Update from NetBSD anoncvs. * monop/cards.c, monop/deck.h, monop/execute.c, monop/getinp.c, monop/houses.c, monop/initdeck.c, monop/jail.c, monop/misc.c, monop/monop.c, monop/monop.def, monop/monop.h, monop/morg.c, monop/print.c, monop/prop.c, monop/rent.c, monop/roll.c, monop/spec.c, monop/trade.c: Update from NetBSD anoncvs. * configure, Makeconfig.in: monop data is now arch-independent. * NEWS: Update. * NEWS: Update. 1999-08-18 Joseph S. Myers * fish/fish.6: Update from NetBSD anoncvs. 1999-08-17 Joseph S. Myers * NEWS: Update. * snake/snake/snake.c: Move to use curses. Other minor fixes. * snake/snake/move.c, snake/snake/snake.h: Remove (incorporated in snake.c). * snake/snake/snake.6.in: Update. * exec.objs: Update. * TODO: Update. * snake/snake/snake.c, snake/snake/move.c: Minor fixes from OpenBSD. 1999-08-16 Joseph S. Myers * backgammon/backgammon/main.c, backgammon/teachgammon/teach.c, fortune/datfiles/fortunes2, snake/snake/move.c, snake/snake/snake.h, tetris/screen.c: Update from NetBSD anoncvs. 1999-08-14 Joseph S. Myers * AUTHORS: Update. * NEWS: Update. * wtf/wtf.in: Update from NetBSD anoncvs. * wtf/acronyms: Update from NetBSD-current. 1999-08-11 Joseph S. Myers * worm/worm.c: Update from NetBSD anoncvs. 1999-08-09 Joseph S. Myers * sail/sync.c: Tweak for NetBSD alignment. * monop/monop.def: Tweak for NetBSD alignment. * rain/rain.c, worm/worm.c: Update from NetBSD anoncvs. 1999-08-06 Joseph S. Myers * fortunes/datfiles/Makefile.bsd, fortune/datfiles/unamerican.fake, fortune/datfiles/unamerican.real, rain/Makefile.bsd, rain/rain.6, rain/rain.c, worms/worms.6, worms/worms.c: Update from NetBSD anoncvs. * fortune/datfiles/Makefrag: Update. 1999-07-29 Joseph S. Myers * adventure/hdr.h, adventure/init.c, atc/graphics.c, backgammon/backgammon/main.c, backgammon/common_source/save.c, battlestar/battlestar.6, battlestar/battlestar.c, battlestar/cypher.c, battlestar/extern.h, battlestar/init.c, battlestar/save.c, bcd/bcd.6, bcd/bcd.c, worm/worm.c, wtf/wtf.in: Update from NetBSD anoncvs. 1999-07-28 Joseph S. Myers * atc/grammar.y, backgammon/common_source/back.h, backgammon/common_source/fancy.c, backgammon/common_source/subs.c: Update from NetBSD anoncvs of yesterday. 1999-07-27 Joseph S. Myers * TODO, SECURITY, PACKAGING: Add note on security hardening. * phantasia/phantglobs.h: Mark `catchalarm' as noreturn. * sail/extern.h: Mark `play' as noreturn. * snake/snake/snake.h: Mark `mainloop' as noreturn. * tetris/screen.c: Mark `stopset' as noreturn. * trek/trek.h: Mark `lose', `myreset', `play' and `win' as noreturn. * bcd/bcd.6: Fix mdoc usage in references. * adventure/hdr.h, adventure/init.c: Fix use of linker commons. * battlestar/extern.h, battlestar/globals.c: Likewise. * backgammon/common_source/fancy.c: Likewise. * sail/extern.h, sail/globals.c, sail/player.h, sail/pl_7.c: Likewise. * snake/snake/snake.h, snake/snake/snake.c: Likewise. * tetris/screen.h, tetris/screen.c, tetris/tetris.h, tetris/tetris.c: Likewise. * trek/trek.h, trek/externs.c: Likewise. * TODO: Update. * backgammon/common_source/save.c (save): Fix other case of executable save files. * atc/graphics.c (getAChar): Be yet more paranoid about EINTR. * atc/input.c (delayb, benum): Revert old unsigned char change (NetBSD now casts the subscripts to int). * configure: Check for fgetln and getloadavg in case they are added to glibc in future. * include/stdio.h: Update. * include/stdlib.h: Update. * lib/fgetln.c: Update. * lib/getloadavg.c: Update. * Makeconfig.in: Add GETLOADAVG_DEFS and FGETLN_DEFS. * battlestar/Makefrag, dm/Makefrag, quiz/Makefrag: Use them. 1999-07-26 Joseph S. Myers * battlestar/battlestar.6: Fix mdoc usage (use .Op Ar saved-file instead of .Op saved-file). * wtf/wtf.in, wtf/wtf.6.in: Update from NetBSD anoncvs. 1999-07-25 Joseph S. Myers * atc/grammer.y, atc/graphics.c, atc/input.c, atc/log.c, atc/main.c, atc/update.c, backgammon/teachgammon/ttext1.c: Update from NetBSD anoncvs. 1999-07-24 Joseph S. Myers * atc/main.c: Change to use getopt. * substfiles: Fix error. * backgammon/common_source/init.c: Whitespace alignment with NetBSD. 1999-07-23 Joseph S. Myers * Makefile.bsd, atc/grammar.y, backgammon/backgammon/main.c, backgammon/teachgammon/teach.c, banner/banner.c, battlestar/battlestar.c, battlestar/com6.c, battlestar/extern.h, bcd/bcd.c, boggle/boggle/bog.c, caesar/caesar.c, trek/computer.c, trek/externs.c, trek/getpar.c, trek/getpar.h, trek/help.c, trek/kill.c, trek/lose.c, trek/out.c, trek/phaser.c, trek/play.c, trek/setup.c, trek/shield.c, trek/srscan.c, trek/systemname.c, trek/trek.h, trek/win.c: Update from NetBSD-current of 1999-07-23. * wtf/wtf.6.in, wtf/wtf.in: New game. * wtf/Makefrag: New file. * configure, substfiles, Makeconfig.in: Update. * wtf/acronyms: Acronym collection from NetBSD. * README, bsd-games.lsm, NEWS: Update. 1999-07-18 Joseph S. Myers * atc/grammar.y (wdef): Check sp->width instead of sp->height. * INSTALL, TODO: Update for egcs/gcc terminology change. * adventure/save.c, arithmetic/arithmetic.c, atc/Makefile.bsd, atc/atc.6.in, atc/extern.h, atc/input.c, atc/log.c, atc/main.c, atc/struct.h: Update from NetBSD-current of 1999-07-18. * battlestar/save.c, battlestar/extern.h, battlestar/init.c, battlestar/cypher.c: Change saving interface again; new function save_file_name() determines the name under which to save. * battlestar/com6.c, battlestar/extern.h: Don't include in com6.c, include it instead of in extern.h. 1999-07-16 Joseph S. Myers * adventure/hdr.h, adventure/main.c, adventure/save.c, adventure/setup.c, adventure/wizard.c, backgammon/backgammon/main.c, battlestar/com1.c, battlestar/com2.c, battlestar/com5.c, battlestar/dayfile.c, battlestar/globals.c, battlestar/nightfile.c, boggle/boggle/bog.c, dm/dm.c, fish/fish.c, wump/wump.c: Update from NetBSD-current of 1999-07-16 (more of my changes merged back in). 1999-07-15 Joseph S. Myers * adventure/save.c (restore): Check for errors writing the save file. 1999-07-14 Joseph S. Myers * boggle/boggle/bog.c (checkdict): Use SEEK_SET with dictseek(). * atc/atc.6.in: New atc.6 from NetBSD-current of 1999-06-28, parametrised. * substfiles: Include atc/atc.6. 1999-06-30 Joseph S. Myers * battlestar/fly.c, fish/fish.c, hunt/hunt/otto.c, robots/Makefile.bsd, robots/auto.c, robots/extern.c, robots/main.c, robots/make_level.c, robots/move.c, robots/move_robs.c, robots/robots.6, robots/robots.h, robots/score.c, rogue/Makefile.bsd, sail/player.h, trek/trek.6.in: Update from NetBSD-current of 1999-05-18. * exec.objs: Update. * INSTALL, NEWS: Note score file format change. * robots/auto.c, robots/robots.h, robots/extern.c, robots/score.c: Fix new warnings. * backgammon/common_source/back.h: Mark `norec' and `errexit' as `noreturn'. * hangman/hangman.h: Mark `die' as `noreturn'. * hunt/huntd/hunt.h: Mark `bad_con', `bad_ver', `sigterm' and `sigemt' as `noreturn'. * phantasia/setup.c: Mark `Error' as `noreturn'. * pom/pom.c: Mark `badformat' as `noreturn'. * random/random.c: Mark `usage' as `noreturn'. * rogue/rogue.h: Mark `killed_by' and `win' as `noreturn'. 1999-04-10 Joseph S. Myers * BUGS: Update. 1999-04-04 Joseph S. Myers * Version 2.7. * bsd-games.lsm, bsd-games-non-free.lsm: Update. * mille/mille.c, mille/misc.c, mille/move.c, mille/save.c: Update from NetBSD-current of 1999-04-02. 1999-03-28 Joseph S. Myers * INSTALL: Update. * NEWS: Update. * mille/print.c (prscore): Mark parameter `for_real' possibly unused. * atc/input.c: Mark unused parameters (detected by current egcs snapshots but not by egcs 1.1) as such. * tetris/scores.c: Use error reporting functions. * hunt/huntd/driver.c (init): Fork and exit to ensure that setsid() will work. 1999-03-27 Joseph S. Myers * backgammon/backgammon/main.c (main): Fix scoring if you bear off all your men and your opponent has borne off at least one man but has a man in your inner board or on the bar (thanks to Stuart Lamble ). * THANKS: Update. * arithmetic/arithmetic.6, backgammon/common_source/Makefile.bsd, battlestar/cypher.c, canfield/canfield/canfield.6.in, countmail/countmail.6, dm/dm.conf.5.in, fortune/strfile/strfile.8, gomoku/gomoku.6, random/random.6, tetris/tetris.c, worms/worms.6: Update from NetBSD-current of 1999-03-26. 1999-02-20 Joseph S. Myers * adventure/crc.c, adventure/hdr.h, adventure/init.c, adventure/io.c, adventure/main.c, adventure/setup.c, adventure/wizard.c, atc/Makefile.bsd, backgammon/backgammon/main.c, backgammon/backgammon/text.c, backgammon/backgammon/version.c, backgammon/common_source/Makefile.bsd, backgammon/common_source/back.h, backgammon/common_source/board.c, backgammon/common_source/fancy.c, backgammon/common_source/init.c, backgammon/common_source/save.c, backgammon/common_source/subs.c, backgammon/common_source/table.c, backgammon/teachgammon/Makefile.bsd, backgammon/teachgammon/data.c, backgammon/teachgammon/teach.c, backgammon/teachgammon/ttext1.c, backgammon/teachgammon/ttext2.c, backgammon/teachgammon/tutor.c, backgammon/teachgammon/tutor.h, battlestar/com1.c, battlestar/com4.c, battlestar/com6.c, battlestar/dayobjs.c, battlestar/extern.h, battlestar/getcom.c, battlestar/globals.c, battlestar/init.c, battlestar/misc.c, battlestar/nightobjs.c, battlestar/parse.c, battlestar/room.c, boggle/Makefile.bsd, boggle/boggle/Makefile.bsd, boggle/mkdict/Makefile.bsd, boggle/mkindex/Makefile.bsd, canfield/cfscores/Makefile.bsd, countmail/Makefile.bsd, cribbage/Makefile.bsd, fish/Makefile.bsd, fortune/datfiles/Makefile.bsd, fortune/unstr/Makefile.bsd, monop/Makefile.bsd, morse/Makefile.bsd, ppt/Makefile.bsd, primes/Makefile.bsd, quiz/Makefile.bsd, sail/assorted.c, sail/dr_1.c, sail/dr_2.c, sail/dr_3.c, sail/dr_4.c, sail/dr_5.c, sail/extern.h, sail/parties.c, sail/pl_1.c, sail/pl_3.c, sail/pl_4.c, sail/pl_5.c, sail/pl_6.c, sail/pl_7.c, sail/pl_main.c, sail/sync.c, snake/snscore/Makefile.bsd, tetris/tetris.c, wargames/Makefile.bsd, wump/Makefile.bsd, wump/wump.c: Update from NetBSD-current of 1999-02-19. * backgammon/teachgammon/ttext1.c: Add more use of const. 1999-01-21 Joseph S. Myers * fortune/fortune/fortune.c: Use strlen(d_name) rather than incorrect #define d_namlen d_reclen. Should be conditionalised in some way. 1999-01-12 Joseph S. Myers * bcd/bcd.6: Include references to the relevant standards. 1999-01-10 Joseph S. Myers * worms/worms.c (main): Use leaveok(). * rain/rain.c (main): Use leaveok(). 1999-01-09 Joseph S. Myers * adventure/hdr.h: Add comment saying where to find original source. * adventure/hdr.h, adventure/main.c, adventure/save.c, adventure/wizard.c: Change saved to saveday where appropriate. This shouldn't actually change the behaviour of the program, except perhaps when saving a game fails, but makes things a lot clearer. * pom/pom.c: Update from the 3rd edition of the reference book. Make date calculation work before the epoch. Fix bug in waxing/waning display near full moon. Use a sensible input date format. (Based on Paul Janzen's work in OpenBSD.) * pom/pom.6: Update. 1999-01-08 Joseph S. Myers * battlestar/cypher.c (cypher): Add FALLTHROUGH comment as per NetBSD policy. * backgammon/backgammon/main.c: Remove unused junk to limit number of users (performed by dm); use \a instead of \007. * adventure/init.c, arithmetic/arithmetic.c, atc/grammar.y, atc/graphics.c, atc/log.c, atc/main.c, atc/update.c, backgammon/backgammon/main.c, backgammon/common_source/subs.c, teachgammon/teach.c, battlestar/com6.c, battlestar/fly.c, boggle/boggle/mach.c, canfield/canfield/canfield.c, cribbage/io.c, cribbage/score.c, dm/dm.c, fortune/fortune/fortune.c, fortune/unstr/unstr.c, gomoku/main.c, gomoku/pickmove.c, hangman/main.c, hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/huntd/faketalk.c, mille/mille.c, monop/monop.c, phantasia/io.c, robots/main.c, rogue/init.c, sail/main.c, sail/pl_1.c, sail/pl_7.c, snake/snake/snake.c, tetris/tetris.c, trek/abandon.c, trek/capture.c, trek/cgetc.c, trek/computer.c, trek/dcrept.c, trek/destruct.c, trek/dock.c, trek/dumpgame.c, trek/help.c, trek/impulse.c, trek/lrscan.c, trek/phaser.c, trek/play.c, trek/rest.c, trek/setwarp.c, trek/torped.c, trek/visual.c, worm/worm.c: Change `unused' parameters to `__unused__'. * bcd/bcd.6: Update from NetBSD-current of 1999-01-07. * phantasia/oldplayer.h: Remove (removed in NetBSD-current on response to my PR bin/6700, and unused since phantasia/convert.c was removed some time ago). * tetris/input.c, tetris/input.h, tetris/screen.c, tetris/tetris.6.in, tetris/tetris.c, tetris/tetris.h: Update from NetBSD-current of 1999-01-07 (adds piece preview option). 1999-01-07 Joseph S. Myers * fortune/strfile/strfile.c (main): Flush output file and check for write errors before closing it and exiting the program. * include/sys/cdefs.h: Use __unused__ in attribute, for cleanness and NetBSD alignment. 1999-01-01 Joseph S. Myers * fortune/strfile/strfile.c: Remove unused ALWAYS macro. * adventure/setup.c, boggle/mkdict/mkdict.c, boggle/mkindex/mkindex.c, monop/initdeck.c: Flush stdout or output file and check for errors on writing before terminating. 1998-12-28 Joseph S. Myers * pig/pig.6: Include utility name with .Nm where needed. * TODO: Update. * atc/extern.h: Whitespace adjustment for NetBSD alignment. * battlestar/com1.c, battlestar/com2.c, battlestar/com5.c, battlestar/dayfile.c, battlestar/globals.c, battlestar/nightfile.c: Spelling and punctuation corrections from OpenBSD. 1998-12-23 Joseph S. Myers * worms/worms.c, worms/worms.6: Convert to use curses; add delay option from OpenBSD; change to use functions; fix signal handling. * TODO: Update. * rain/rain.c, rain/rain.6: Convert to use curses; add delay option from OpenBSD; fix signal handling. * TODO: Update. 1998-12-20 Joseph S. Myers * install-man.in: Use `ln -sf' rather than `ln -s'. How come this never got noticed before? * Version 2.6. * configure: Really fix quiz/datfiles/index generation. * NEWS: Update. * bsd-games.lsm: Update. * bsd-games-non-free.lsm: Update. 1998-12-18 Joseph S. Myers * ppt/ppt.c: Print a space between command line arguments (bugfix from OpenBSD). 1998-12-14 Joseph S. Myers * configure (warning_flags): Add -Wwrite-strings to defaults. * TODO: Update. * NEWS: Update. * sail/assorted.c, sail/dr_1.c, sail/dr_2.c, sail/driver.h, sail/extern.h, sail/globals.c, sail/lo_main.c, sail/pl_3.c, sail/pl_4.c, sail/pl_7.c: Use const where appropriate. * tetris/scores.c, tetris/screen.c, tetris/shapes.c, tetris/tetris.c, tetris/tetris.h: Use const where appropriate. * snake/snake/move.c, snake/snake/snake.c, snake/snake/snake.h, snake/snscore/snscore.c: Use const where appropriate. 1998-12-12 Joseph S. Myers * sail/assorted.c, sail/dr_1.c, sail/dr_2.c, sail/dr_3.c, sail/dr_4.c, sail/dr_5.c, sail/extern.h, sail/parties.c, sail/pl_1.c, sail/pl_3.c, sail/pl_4.c, sail/pl_5.c, sail/pl_6.c, sail/pl_7.c, sail/pl_main.c, sail/sync.c: Split Write() into two separate functions for string and numeric arguments. * robots/extern.c, robots/init_field.c, robots/main.c, robots/move.c, robots/query.c, robots/robots.h, robots/score.c: Use const where appropriate. * quiz/quiz.c, quiz/quiz.h, quiz/rxp.c: Use const where appropriate. * phantasia/gamesupport.c, phantasia/interplayer.c, phantasia/io.c, phantasia/main.c, phantasia/misc.c, phantasia/phantglobs.c, phantasia/phantglobs.h, phantasia/phantstruct.h, phantasia/setup.c: Use const where appropriate. 1998-12-11 Joseph S. Myers * NEWS: Update. * monop/cards.c, monop/execute.c, monop/getinp.c, monop/initdeck.c, monop/misc.c, monop/monop.def, monop/monop.ext, monop/monop.h, monop/morg.c, monop/print.c, monop/spec.c, monop/trade.c: Use const where appropriate. * trek/computer.c, trek/externs.c, trek/getpar.h, trek/getpar.c, trek/help.c, trek/kill.c, trek/lose.c, trek/out.c, trek/phaser.c, trek/play.c, trek/setup.c, trek/shield.c, trek/srscan.c, trek/systemname.c, trek/trek.h, trek/win.c: Use const where appropriate. * TODO: Update. * fortune/fortune/fortune.c: Use const where appropriate. * rain/rain.c: Use const where appropriate. * number/number.c: Use const where appropriate. 1998-12-10 Joseph S. Myers * morse/morse.c: Use const where appropriate. * worm/worm.c: Use const where appropriate. * worms/worms.c: Include instead of providiing prototypes for termcap functions; use const where appropriate; tputs fixes. * wump/wump.c (instructions): Use const where appropriate. * phantasia/fight.c, phantasia/gamesupport.c, phantasia/interplayer.c, phantasia/main.c, phantasia/misc.c: Use symbolic argument with fseek. * sail/sync.c: Use symbolic argument with fseek. * monop/initdeck.c: Use symbolic argument with fseek. * monop/cards.c (get_card): Use symbolic argument with fseek. * hangman/getword.c (getword): Use symbolic argument with fseek. * fortune/fortune/fortune.c, fortune/strfile/strfile.c, fortune/unstr/unstr.c: Use symbolic argument with fseek. * boggle/boggle/bog.c: Use symbolic argument with dictseek (which gets passed to fseek). * BUGS: Update. * rogue/save.c (save_into_file): Check for allocation failure. * rogue/init.c: Check for allocation failure. * snake/snscore/snscore.c (main): Check for allocation failure. * worm/worm.c: Check for allocation failure. * monop/prop.c (add_list): Check for allocation failure. * monop/monop.c (getplayers): Check for allocation failure. * monop/initdeck.c (main): Check for allocation failure; use symbolic argument for fseek; exit with error status if opening output file fails. * monop/cards.c (set_up): Check for allocation failure. * monop/monop.h: Include . 1998-12-08 Joseph S. Myers * adventure/wizard.c (ciao): Avoid buffer overrun when reading save file name. * morse/morse.c, phantasia/Makefile.bsd, quiz/Makefile.bsd, rogue/hit.c, rogue/init.c, rogue/inventory.c, rogue/level.c, rogue/machdep.c, rogue/message.c, rogue/monster.c, rogue/move.c, rogue/object.c, rogue/pack.c, rogue/play.c, rogue/ring.c, rogue/rogue.h, rogue/room.c, rogue/save.c, rogue/score.c, rogue/throw.c, rogue/trap.c, rogue/use.c, rogue/zap.c, wump/Makefile.bsd: Update from NetBSD-current of 1998-12-07. 1998-12-07 Joseph S. Myers * atc/Makefile.bsd, atc/extern.c, atc/extern.h, atc/graphics.c, atc/input.c, atc/log.c, atc/main.c, atc/update.c, backgammon/backgammon/main.c, backgammon/common_source/subs.c, backgammon/teachgammon/teach.c, bcd/bcd.6, boggle/Makefile.bsd, boggle/boggle/Makefile.bsd, cribbage/Makefile.bsd, fish/Makefile.bsd, fortune/datfiles/Makefile.bsd, fortune/datfiles/fortunes, fortune/datfiles/fortunes.sp.ok, monop/Makefile.bsd: Update from NetBSD-current of 1998-12-07. * exec.objs: Remove references to lib/select.o. * lib/select.c: Remove. * hunt/huntd/driver.c (main): Initialise linger when required to avoid need for select() wrapper. * hunt/huntd/ctl_transact.c (ctl_transact): Reinitialise wait to avoid need for select() wrapper. * hunt/hunt/hunt.c (list_drivers): Reinitialise wait in each cycle, so as not to need select() wrapper. * README: Update. * TODO: Update. * tetris/tetris.c (main): Die if fds 0, 1, 2 aren't already open. * snake/snake/snake.c (main): Die if score file gets fd < 3. * sail/main.c (main): Die if fds 0, 1, 2 aren't already open. * sail/sync.c: Size sync_lock and sync_file according to the length required for the name formatted. * rogue/init.c (init): Die if fds 0, 1, 2 aren't already open. * robots/main.c (main): Die if the score file gets fd < 3. * phantasia/main.c (initialstate): Die if the first file opened gets fd < 3. * cribbage/crib.c (main): Die if the score file gets fd < 3. * canfield/canfield/canfield.c (initall): Die if the score file gets fd < 3. * battlestar/com6.c (open_score_file): Die if the score file gets fd < 3. * atc/log.c (open_score_file): Die if the score file gets fd < 3. 1998-12-06 Joseph S. Myers * TODO: Update. * sail/pl_main.c (initialize): Use snprintf, not sprintf. This fixes a possible buffer overrun; it comes from RedHat and the LSAP, though neither ever bothered to send it to me. * configure: Don't put `#!/bin/sh' and an `autogenerated' comment in quiz/datfiles/index. 1998-09-24 Joseph S. Myers * Version 2.5. * bsd-games.lsm, bsd-games-non-free.lsm: Update. * Paul Janzen has checked with the original author, and it turns out the the BSD licence applies to boggle and obsoletes the old one, so boggle can go in the main bsd-games package. * boggle/README: Update accordingly. * boggle/README.linux, boggle/Makefrag: Update accordingly. No longer need to include uuencoded patch. * boggle/boggle/helpfile: Update accordingly. * INSTALL: Update accordingly. * NEWS: Update accordingly. * PACKAGING: Update accordingly. * README, README.non-free: Update accordingly. * bsd-games.lsm, bsd-games-non-free.lsm: Update accordingly. * TODO: Update accordingly. * THANKS: Update accordingly. 1998-09-23 Joseph S. Myers * NEWS: Update. * trek/main.c: Make Mother uid_t. * hunt/hunt/hunt.c: Don't declare errno. * hunt/huntd/hunt.h: Don't declare errno - include instead. * factor/Makefrag: Define _GNU_SOURCE, for isblank(). * number/Makefrag, primes/Makefrag: Likewise. * With glibc 2.1, various headers can be included with an __need_foo preprocessor define to make them only define some particular symbols; this interacts badly with multiple inclusion protection on the header wrappers in bsd-games. Therefore, we must not protect wrapper headers against multiple inclusion, but instead make sure they are safe to be included multiple times and only protect local bits that need it. * include/signal.h: Don't protect against multiple inclusion - only protect the sig_t definition that needs it. * include/stdlib.h: Don't protect against multiple inclusion. * include/stdio.h: Don't protect against multiple inclusion. * include/termios.h: Don't protect against multiple inclusion. * include/sys/cdefs.h: Don't protect against multiple inclusion. * include/sys/ttydefaults.h: Don't protect against multiple inclusion. * dm/dm.c: Don't include - it isn't needed, and doesn't exist with some glibc versions. * INSTALL: Minor changes. 1998-09-15 Joseph S. Myers * atc/Makefile.bsd, atc/extern.h, atc/input.c, atc/main.c, backgammon/backgammon/backgammon.6.in, backgammon/common_source/back.h, backgammon/common_source/fancy.c, backgammon/common_source/save.c, backgammon/common_source/subs.c, backgammon/teachgammon/tutor.h, banner/banner.c, battlestar/extern.h, battlestar/save.c, boggle/boggle/extern.h, caesar/caesar.c, canfield/canfield/canfield.c, cribbage/cribbage.h, dm/dm.c, factor/factor.c, fish/fish.c, fortune/datfiles/fortunes, fortune/fortune/fortune.c, fortune/strfile/strfile.c, gomoku/gomoku.h, hunt/hunt/hunt.c, hunt/huntd/hunt.h, mille/mille.h, number/number.c, pig/pig.c, primes/primes.c, quiz/quiz.c, robots/robots.h, rogue/rogue.h, sail/extern.h, snake/snake/snake.h, tetris/tetris.c, tetris/tetris.h, worm/worm.c, worms/worms.c, wump/wump.c: Update from NetBSD-current of 1998-09-14. * atc/games/ATC_Scores, sail/:file, sail/:scene, sail/:ship, sail/:specs, trek/board.x: Removed (unused, and removed in NetBSD-current of 1998-09-14 in response to PR bin/6083). 1998-09-14 Joseph S. Myers * adventure/done.c, adventure/extern.h, adventure/io.c, adventure/main.c, adventure/setup.c, adventure/subr.c, adventure/vocab.c, arithmetic/arithmetic.c: Update from NetBSD-current of 1998-09-14. * mille/move.c: Remove unused Movenames[] array. * mille/comp.c, mille/mille.h, mille/extern.c, mille/move.c, mille/save.c, mille/print.c: Use const where appropriate. * robots/robots.h: #undef S_BONUS before defining. * mille/mille.h: #undef S_* constants before defining. * atc/def.h: #undef S_* constants before defining. * hunt/hunt/connect.c, hunt/huntd/hunt.h, hunt/hunt/main.c, hunt/hunt/playit.c, hunt/huntd/answer.c, hunt/huntd/draw.c, hunt/huntd/faketalk.c, hunt/huntd/get_names.c, hunt/huntd/pathname.c, hunt/huntd/terminal.c, hunt/huntd/driver.c: Use const where appropriate. * hangman/extern.c, hangman/hangman.h, hangman/setup.c: Use const where appropriate. 1998-09-13 Joseph S. Myers * gomoku/bdisp.c, gomoku/gomoku.h, gomoku/main.c, gomoku/makemove.c, gomoku/pickmove.c, gomoku/stoc.c: Use const where appropriate. * configure: Generate GNUmakefile, not Makefile - the makefile and makefile fragments are thoroughly dependent on GNU Make. * backgammon/common_source/back.h: No longer any need to define OXTABS. * snake/snake/move.c: No longer any need to define CTRL or OXTABS. * tetris/screen.c: No longer any need to define OXTABS. * mille/misc.c: No longer any need to define CTRL. * snake/snake/snake.c: No longer any need to define CTRL. * include/sys/ttydefaults.h: Define OXTABS if not already defined. * include/termios.h: New file, also include . * THANKS: Update. * adventure/crc.c: Mark crctab[] const. * adventure/vocab.c (vocab): Use errx() for error messages. * adventure/main.c (main): Use bug(22) rather than printing "Error 22". * adventure/io.c (rdesc): Use errx() for error messages. * monop/Makefile.bsd: Update from NetBSD-current of 1998-09-13. * adventure/crc.c, adventure/extern.h, adventure/io.c, adventure/save.c, adventure/vocab.c: Update from NetBSD-current of 1998-09-13 (const changes merged into NetBSD). 1998-09-12 Joseph S. Myers * All games now updated from NetBSD-current of 1998-09-12. * adventure/extern.h, adventure/main.c, atc/def.h, atc/update.c, backgammon/common_source/subs.c, battlestar/battlestar.6, bcd/bcd.6, boggle/mkindex/mkindex.c, canfield/canfield/canfield.c, hangman/hangman.h, hangman/main.c, hunt/huntd/hunt.h, monop/execute.c, monop/monop.c, pom/pom.c, rogue/monster.c, rogue/object.c, rogue/pack.c, rogue/room.c, sail/dr_2.c, sail/sync.c, snake/snscore/snscore.c, trek/dumpgame.c, trek/warp.c: Update from NetBSD-current of 1998-09-12. 1998-09-11 Joseph S. Myers * BUGS: Update. * SECURITY: Update. * INSTALL: Update. * NEWS: Update. * TODO: Update. 1998-09-10 Joseph S. Myers * adventure/io.c (pspeak): Give "Out of memory!" error on allocation failure rather than bug(108). 1998-09-07 Joseph S. Myers * boggle/README.linux, boggle/Makefrag: Update. 1998-09-06 Joseph S. Myers * */Makefrag: Further changes for the new build system. 1998-09-05 Joseph S. Myers * New configuration/build system, based on a single makefile that includes makefile fragments that together describe all the dependencies (using GNU make's automatic dependency generation). See `Recursive Make Considered Harmful' by Peter Miller for a discussion of the advantages of this over recursive make. * configure, install-score.in, Makeconfig.in: Changes for the new system. * Makefile: Removed. * mkdep, exec.libs, exec.objs: New files. * */Makefile, */*/Makefile: Renamed to Makefrag and changed for the new system. * hunt/Makeconfig: Adapted to the new system. * backgammon/README.linux: Removed. * TODO: Update. * PACKAGING: Update. * INSTALL: Update. * fortune/fortune/pathnames.in: Remove TEST support. * fortune/README.linux: Update. * Version 2.4. * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. * TODO: Update. * INSTALL: Update. * BUGS: Update. 1998-09-04 Joseph S. Myers * backgammon/teachgammon/Makefile (COBJS): No need to include odds.o. * TODO: Update. * NEWS: Update. * THANKS: Update. * dm/dm.c: Allow time-based games play to be turned off from 11pm to midnight; remove spurious terminal full stop from err() string (patch from Paul Janzen ). 1998-09-02 Joseph S. Myers * NEWS: Update. * lib/fgetln.c (fgetln): Check for allocation failure. * hunt/huntd/shots.c (chkslime): Check for allocation failure. * hunt/huntd/expl.c (showexpl): Check for allocation failure. * hunt/hunt/hunt.c: Check for allocation failure. * gomoku/pickmove.c: Check for allocation failure. * BUGS: Update about gomoku defect. * INSTALL: Update egcs 1.1 references. * battlestar/dayobjs.c (dayobjs): Add missing initialiser at end. * battlestar/nightbojs.c (nightobjs): Likewise. 1998-09-01 Joseph S. Myers * backgammon/common_source/fancy.c (getcaps): Check for allocation failure. * atc/graphics.c (loser): Check for p being NULL, which it could be if we tun out of memory. * atc/update.c: Allow for newplane() to return NULL if out of memory. * adventure/vocab.c (vocab): Check for memory allocation failure. * adventure/io.c (rtrav): Check for memory allocation failure. * NEWS: Update. * rogue/save.c (save_into_file): Avoid buffer overrun. * rogue/Makefile (object.o): Build object.o with -fwritable-strings - the other files don't need it. Also don't build curses.c. * TODO: Update. * rogue/rogue.h: Undefine CURSES after including . * rogue/rogue.h, rogue/hit.c, rogue/message.c, rogue/init.c, rogue/machdep.c, rogue/save.c, rogue/inventory.c, rogue/object.c, rogue/level.c, rogue/monster.c, rogue/pack.c, rogue/play.c, rogue/ring.c, rogue/room.c, rogue/score.c, rogue/throw.c, rogue/trap.c, rogue/use.c, rogue/zap.c, rogue/move.c: Use const where appropriate. * fish/fish.c: Use const where appropriate. * phantasia/io.c (getanswer): Mark loop, oldx, oldy volatile. 1998-08-31 Joseph S. Myers * adventure/setup.c (main): String passed to err() shouldn't have full stop at its end. * factor/factor.c, primes/pr_tbl.c, primes/primes.c, primes/pattern.c: Use const where appropriate. * dm/dm.c: Use const where appropriate. * cribbage/cribbage.h, cribbage/cards.c, cribbage/instr.c, cribbage/io.c, cribbage/score.c, cribbage/support.c: Use const where appropriate. 1998-08-30 Joseph S. Myers * NEWS: Update. * All games now updated from NetBSD-current of 1998-08-30. * adventure/extern.h, adventure/hdr.h, adventure/init.c, adventure/io.c, backgammon/backgammon/main.c, backgammon/common_source/save.c, backgammon/teachgammon/teach.c, battlestar/com5.c, boggle/boggle/bog.c, canfield/canfield/canfield.c, canfield/cfscores/cfscores.c, cribbage/crib.c, cribbage/score.c, fortune/fortune/fortune.c, hunt/hunt/hunt.c, monop/cards.c, monop/morg.c, phantasia/fight.c, phantasia/main.c, phantasia/misc.c, sail/dr_1.c, sail/pl_3.c, sail/pl_7.c, sail/sync.c, trek/kill.c, trek/move.c, trek/nova.c, trek/shield.c, wump/wump.c: Update from NetBSD-current of 1998-08-30. * dm/dm.c (main): Do unsetenv("TZ") to prevent people cheating on the times they can play. * atc/main.c (main): Remove comment on ICRNL change. * atc/input.c: Remove CRTOKEN stuff (conditional on SYSV) - no need for it with ICRNL. 1998-08-29 Joseph S. Myers * battlestar/com5.c (give): Add explanatory comment. 1998-08-28 Joseph S. Myers * battlestar/com5.c (give): Proper fix this time: reset wordnumber before doing an error return. * atc/graphics.c (getAChar): Check against EOF, not -1; clearerr(stdin) while the error occurs since the error indicator may have been set; initialise errno to avoid problems with a real EOF and errno left as EINTR. * boggle/boggle/bog.c (compar): Use const more. * INSTALL: Update. * boggle/boggle/bog.c (main): Change linux/PURE variants to NEW_STYLE define. * boggle/boggle/Makefile: NEW_STYLE is default. * boggle/Makefile (linux-patch): Change construction of Linux patch. * boggle/README.linux: Adjust accordingly. * INSTALL: Likewise. * sail/extern.h, sail/dr_1.c, sail/dr_2.c, sail/dr_3.c: Rename strend() to str_end(), isolated() to is_isolated(), toughmelee() to is_toughmelee(). * phantasia/phantdefs.h: #undef S_* constants before definition. * monop/monop.h, monop/misc.c, monop/trade.c: Rename isnot_monop() to is_not_monop(). * mille/mille.h, mille/comp.c, mille/init.c, mille/move.c, mille/types.c: Rename issafety to is_safety, isrepair to is_repair. 1998-08-27 Joseph S. Myers * hunt/huntd/hunt.h, hunt/huntd/draw.c, hunt/huntd/shots.c: Rename isplayer to is_player. * gomoku/gomoku.h, gomoku/main.c: Rename log() to glog(). * cribbage/cards.c, cribbage/cribbage.h, cribbage/io.c: Rename isone() to is_one(). * backgammon/common_source/fancy.c, backgammon/common_source/back.h: Remove tos(). * boggle/boggle/help.c (help): Make change to use redrawwin() conditional on NCURSES_VERSION. * configure: Suggest mode 2770 for sail directory, better than 0770. * NEWS: Update. * PACKAGING: Add new Warnings section. * battlestar/extern.h, battlestar/com6.c, battlestar/init.c: Change uname[] to username[]. * backgammon/teachgammon/tutor.h: Mark leave() and tutor() noreturn. * TODO: Update. * BUGS: Update. 1998-08-26 Joseph S. Myers * adventure/vocab.c (vocab): Exit with status 1 on error. * adventure/main.c (main): Exit with status 1 on error. * adventure/io.c (rdesc): Exit with status 1 on error. * adventure/hdr.h (FLUSHLINE): Handle EOF. * adventure/io.c: Handle EOF. * adventure/wizard.c (ciao): Handle EOF. * adventure/setup.c: Don't put \n in error strings (err and errx add it). * backgammon/backgammon/main.c: Change condition on ospeed being declared to #ifndef NCURSES_VERSION. * backgammon/teachgammon/teach.c: Likewise. * snake/snake/move.c: Likewise. * snake/snake/snake.h: Likewise. * tetris/screen.c: Likewise. * backgammon/backgammon/text.c (text): Switch order of char and const. * battlestar/cypher.c (cypher): In take all, handle BATHGOD and NORMGOD properly. * rogue/machdep.c (md_slurp): Use POSIX version unconditionally. * hunt/huntd/driver.c (init): Use setsid() to become session leader. * canfield/canfield/canfield.c: Use const where appropriate. * canfield/cfscores/cfscores.c: Use const where appropriate. * caesar/caesar.c: Use const where appropriate. * rogue/rogue.h: Condition some prototypes on #ifdef CURSES. 1998-08-25 Joseph S. Myers * atc/graphics.c (getAChar): Just use SYSV version always rather than conditioning on SYSV || __linux__; the efficiency loss on systems where getchar() retries is insignificant. * adventure/extern.h, adventure/init.c, adventure/main.c, adventure/subr.c, adventure/vocab.c, adventure/wizard.c: Update from NetBSD-current of 1998-08-25. * boggle/README.linux: Rebuild. * configure: Suggest sail directory should not be world accessible. * sail/sync.c: Use egid when checking for file existence, so that the sail directory can be mode 770. * boggle/boggle/extern.h, boggle/boggle/word.c, boggle/boggle/prtable.c, boggle/boggle/mach.c, boggle/boggle/bog.c: Use const where appropriate. 1998-08-24 Joseph S. Myers * arithmetic/arithmetic.c: Use const where appropriate. * include/sys/cdefs.h: Use const in __RCSID and __COPYRIGHT. * bcd/bcd.c: Use const where appropriate. * mille/save.c (rest_f): Use O_RDONLY in open(). * adventure/subr.c, adventure/extern.h: Make checkhints(), closing() and caveclose() return void. * adventure/subr.c, adventure/extern.h: Make bug() return void. * adventure/subr.c, adventure/extern.h: badmove()'s return value is never used, so make it void. * adventure/extern.h: twrite() returns void, and is conditioned on #ifdef DEBUG. * adventure/io.c, adventure/extern.h: Remove unused function confirm(). * adventure/done.c, adventure/extern.h, adventure/main.c: die() can only return 2000, so make it void. * battlestar/com2.c, battlestar/com3.c, battlestar/cypher.c: Update from NetBSD-current of 1998-08-24. * battlestar/init.c (getutmp): Use strncpy(). * battlestar/extern.h, battlestar/globals.c, battlestar/words.c, battlestar/dayobjs.c, battlestar/nightobjs.c, battlestar/misc.c, battlestar/init.c, battlestar/com4.c, battlestar/parse.c, battlestar/save.c, battlestar/getcom.c, battlestar/com1.c, battlestar/com6.c, battlestar/room.c: Use const where appropriate. * banner/banner.c: Use const where appropriate. * adventure/io.c: Make tape, iotape const. * backgammon/teachgammon/Makefile: Add dependency on tutor.h. * backgammon/backgammon/main.c, backgammon/backgammon/text.c, backgammon/backgammon/version.c: Use const where appropriate. * backgammon/common_source/save.c: Use , not extern int errno. * backgammon/teachgammon/tutor.c, backgammon/teachgammon/tutor.h, backgammon/teachgammon/data.c, backgammon/teachgammon/teach.c, backgammon/teachgammon/ttext1.c, backgammon/teachgammon/ttext2.c: Use const where appropriate. * backgammon/backgammon/backgammon.6.in, backgammon/common_source/save.c: Remove nonsense about executing save files; open them without execute permission. * backgammon/common_source/save.c: Use symbolic constants in open() and for errno. * backgammon/common_source/fancy.c, backgammon/common_source/back.h, backgammon/common_source/save.c, backgammon/common_source/subs.c, backgammon/common_source/init.c, backgammon/common_source/table.c, backgammon/common_source/board.c: Use const where appropriate. * backgammon/common_source/subs.c, backgammon/common_source/back.h: Remove strset() (not used). 1998-08-23 Joseph S. Myers * TODO: Update. * atc/input.c, atc/extern.h, atc/graphics.c, atc/update.c, atc/main.c, atc/extern.c, atc/log.c: Use const where appropriate. * adventure/hdr.h, adventure/init.c: Make delhit volatile sig_atomic_t; only assign to it. * adventure/crc.c, adventure/extern.h, adventure/io.c, adventure/save.c, adventure/vocab.c: Use const where appropriate. * adventure/vocab.c, adventure/extern.h: Make copystr(), weq() and length() into macros that use standard C library functions. * adventure/wizard.c, adventure/extern.h, adventure/main.c: Remove unused arg of ciao(). * adventure/wizard.c, adventure/extern.h, adventure/init.c, adventure/main.c: Remove unused arg of Start(). * adventure/subr.c, adventure/extern.h, adventure/main.c: Remove unused arg of dark(). * adventure/subr.c, adventure/extern.h, adventure/main.c: Remove unused arg of liq(). * adventure/init.c, adventure/extern.h, adventure/main.c: Remove unused arg of init(). 1998-08-21 Joseph S. Myers * sail/extern.h, sail/main.c, sail/dr_main.c: Remove handling of being setuid - nowadays games only run setgid. * rogue/machdep.c (md_shell): Remove unnecessary setuid(). * fish/fish.c (instructions): Remove setuid() and setgid() in child, no longer necessary. * INSTALL: Add note about the desirability of using tmac.doc from NetBSD. * worm/worm.6: Revert unnecessary changes. * hangman/hangman.6.in: Revert unnecessary changes. * dm/dm.8.in: Revert unnecessary changes. * bcd/bcd.6: Revert unnecessary changes. * backgammon/backgammon/backgammon.6.in: Revert some unnecessary changes. 1998-08-20 Joseph S. Myers * hunt/hunt/hunt.c: Include for MAXHOSTNAMELEN. * snake/snake/move.c, snake/snake/snake.h, snake/snake/snake.c: Rename raw() to my_raw() (from Joey Hess ). * robots/robots.h: Include (from Joey Hess ). 1998-08-19 Joseph S. Myers * number/number.c (convert): Decrement len when there's a minus sign. * Version 2.3. * sail/Makefile (install): Use install prefix. * NEWS: Update. * All games now updated from NetBSD-current of 1998-08-19. * tetris/tetris.c: Update from NetBSD-current of 1998-08-19. * tetris/screen.c: Update from NetBSD-current of 1998-08-19. * TODO: Update. * NEWS: Update. * bsd-games.lsm: Update. * AUTHORS (countmail): Restore. * README: Update. * countmail/*: Restore, updated from NetBSD-current of 1998-08-19 (which has a licence for it). * atc/input.c: Update from NetBSD-current of 1998-08-19. * adventure/Makefile.bsd: Update from NetBSD-current of 1998-08-19. * SECURITY: Update. * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. * boggle/README.linux: Regenerate. * NEWS: Update. * sail/sync.c: Restore privileges when appropriate. * sail/misc.c (logger): Restore privileges for file open. * sail/main.c (main): Initialise gid and egid; drop egid leaving saved gid. * sail/extern.h: Add gid and egid. * sail/Makefile (install): Install sail directory. * sail/sync.c: Use defines from pathnames.h. * sail/pathnames.h.in: Put definitions here. * Makeconfig.in: Add appropriate macros. * configure: Configure a directory for sail temporary files. * sail/*: Revert previous changes. Sail needs to keep privileges for sync file handling. * atc/log.c (log_score): Fix truncate logic. * configure: Remove some of the less useful warning flags just added. * wump/wump.c (int_compare): Use const. * robots/score.c (cmp_sc): Use const. * fortune/strfile/strfile.c (cmp_str): Use const. * boggle/boggle/bog.c (compar): Use const. * atc/log.c (compar): Use const. * configure: Add more warning flags to the default. 1998-08-18 Joseph S. Myers * INSTALL: Minor changes. * wump/wump.c: Mark usage() noreturn. * worms/worms.c: Mark nomem() and onsig() noreturn. * worm/worm.c: Mark leave() and crash() noreturn. * tetris/tetris.c: Mark usage() and onintr() noreturn. * tetris/tetris.h: Mark stop() noreturn. * snake/snake/snake.h: Mark done() and stop() noreturn. * sail/extern.h: Mark leave() and choke() noreturn. * TODO: Update. * rogue/rogue.h: Mark clean_up(), error_save(), md_exit(), put_scores() and sf_error() noreturn. * robots/robots.h: Mark quit() noreturn. * gomoku/gomoku.h: Mark quit(), quitsig() and panic() noreturn. * quiz/quiz.c: Mark usage() noreturn. * primes/primes.c: Mark usage() noreturn. * pig/pig.c: Mark usage() noreturn. * number/number.c: Mark usage() noreturn; remove spurious toobig() prototype (no such function defined or used). * mille/mille.h: Mark die() noreturn. 1998-08-17 Joseph S. Myers * hunt/huntd/hunt.h: Mark cleanup() noreturn. * hunt/hunt/hunt.c: Mark leave() noreturn. * fortune/strfile/strfile.c: Mark usage() noreturn. * fortune/fortune/fortune.c: Mark usage() noreturn. * fish/fish.c: Mark usage() noreturn; actually use it. * cribbage/cribbage.h: Mark rint() noreturn. * factor/factor.c: Mark usage() noreturn. * dm/dm.c: Mark play() noreturn. * canfield/canfield/canfield.c: Mark cleanup() noreturn. * caesar/caesar.c: Mark printit() noreturn. * boggle/boggle/extern.h: Mark usage() noreturn. * boggle/README.linux: Rebuild. * battlestar/extern.h: Mark die(), diesig() and live() noreturn. * backgammon/common_source/back.h: Mark getout() noreturn. * atc/extern.h: Make loser() and log_score_quit() noreturn. * arithmetic/arithmetic.c: Mark intr() and usage() noreturn. * adventure/extern.h: Mark done() noreturn. * adventure/subr.c (bug): Use exit status 1 for a fatal error. * snake/snake/snake.c (post): Use SEEK_SET rather than 0 in lseek(). * robots/score.c (score): Use SEEK_SET rather than 0 in lseek(). * fortune/fortune/fortune.c (get_fort): Use SEEK_SET rather than 0 in lseek(). * canfield/cfscores/cfscores.c (printuser): Use SEEK_SET rather than 0 in lseek(). * canfield/canfield/canfield.c (suspend): Use SEEK_SET rather than 0 in lseek(). (cleanup): Same. * SECURITY: Clarify. 1998-08-15 Joseph S. Myers * Version 2.2. * robots/score.c (score): Check for score file not having been successfully opened. * README: Update. * INSTALL: Update. * configure: Fix typo. * atc/log.c (log_score): Use it, avoiding possible buffer overrun. * atc/struct.h (SCORE_SCANF_FMT): Define to be format for scnaf from score file, with appropriate max field widths. * configure: Update. * bsd-games.lsm: Update. * TODO: Update. * AUTHORS (countmail): Remove. * NEWS: Update. * README: Update. * countmail/*: Remove. * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. * PACKAGING: Update. * BUGS: Update. * NEWS: Update. * TODO: Update. * SECURITY: New file, describing security issues, taken from INSTALL. * INSTALL: Update. * wump/wump.c (main): Revoke setgid privileges. * worms/worms.c (main): Revoke setgid privileges. * worm/worm.c (main): Revoke setgid privileges. * trek/main.c (main): Revoke setgid privileges. * tetris/tetris.c, tetris/score.c: Only have privileged egid when needed. * tetris/tetris.h: New variables gid, egid. * snake/snscore/snscore.c (main): Revoke setgid privileges. * snake/snake/snake.c: Open score files as early as possible, then drop setgid privileges. * sail/misc.c (open_log): New function: opens log file. * sail/extern.h: Declare this. * sail/misc.c (logger): Use already open log file. * sail/main.c: Open log file, then drop privileges. * rogue/init.c, rogue/machdep.c, rogue/score.c: Only have privileged egid when needed. * rogue/init.c: New variables gid, egid; initialise them. * rogue/rogue.h: Declare them; include and . * robots/main.c (main), robots/extern.h, robots/score.c (score): Open score file at start, then drop privileges (from OpenBSD). * cribbage/crib.c (main): Set close-on-exec flag on log file. * random/random.c (main): Revoke setgid privileges. * rain/rain.c (main): Revoke setgid privileges. * quiz/quiz.c (main): Revoke setgid privileges. * primes/primes.c (main): Revoke setgid privileges. * ppt/ppt.c (main): Revoke setgid privileges. * pom/pom.c (main): Revoke setgid privileges. * pig/pig.c (main): Revoke setgid privileges. * number/number.c (main): Revoke setgid privileges. * morse/morse.c (main): Revoke setgid privileges. * monop/monop.c (main): Revoke setgid privileges. * mille/mille.c (main): Revoke setgid privileges. * hunt/hunt/hunt.c (main): Revoke setgid privileges. * hangman/main.c (main): Revoke setgid privileges. * gomoku/main.c (main): Revoke setgid privileges. * fortune/fortune/fortune.c (main): Revoke setgid privileges. * fish/fish.c (main): Revoke setgid privileges. * factor/factor.c (main): Revoke setgid privileges. * cribbage/crib.c (main): Open log file then drop privileges as soon as possible. * canfield/canfield/canfield.c (initall): Use SEEK_SET instead of 0 as argument of lseek(). * canfield/cfscores/cfscores.c (main): Revoke setgid privileges. * canfield/canfield/canfield.c (initall): Revoke setgid privileges after opening the score file. 1998-08-13 Joseph S. Myers * boggle/README.linux: Rebuild. * caesar/caesar.c (main): Revoke setgid privileges. * boggle/boggle/bog.c (main): Revoke setgid privileges. * bcd/bcd.c (main): Revoke setgid privileges. * battlestar/com6.c (open_score_file), battlestar/extern.h: New function. * battlestar/com6.c (post): Use already opened score file. * battlestar/battlestar.c (main): Open score file then revoke setgid privileges. * atc/input.c (gettoken): Remove unnecessary setuid() call. 1998-08-11 Joseph S. Myers * AUTHORS (paranoia): Removed entry. * bsd-games-non-free.lsm: Update. * INSTALL: Update. * atc/log.c (open_score_file): Set close-on-exec flag. * TODO: Update. * PACKAGING: Update. * Credits: Split into AUTHORS and THANKS; update. * BUGS: Update. 1998-08-09 Joseph S. Myers * battlestar/extern.h, battlestar/save.c, battlestar/init.c, battlestar/cypher.c, battlestar/battlestar.c: New interface for saving, passes length and does dynamic allocation rather than using fixed length buffers. * battlerstar/Makefile: Include fgetln. * banner/banner.c (main): Revoke setgid privileges. * backgammon/backgammon/main.c (main): Revoke setgid privileges. * atc/log.c: Cast getuid() return value to int for %d format. * atc/log.c (open_score_file), atc/extern.h: New function. * atc/log.c (log_score): Use already opened score file. Truncate the score file to the length written. * atc/main.c (main): Open the score file and then revoke setgid privileges. * arithmetic/arithmetic.c (main): Revoke setgid privileges. * adventure/main.c (main): Revoke setgid privileges. * snake/snscore/snscore.c (main): Take no arguments. * hangman/extern.h, hangman/main.c (main): Take no arguments. * canfield/canfield/canfield.c (main): Take no arguments. 1998-08-07 Joseph S. Myers * README.non-free: Update. * README: Update. * paranoia/*: Remove. * NEWS: Update. * INSTALL: Update. 1998-08-06 Joseph S. Myers * configure: Add facility to specify a list of games not to build. * TODO: Update. * README: Update. * PACKAGING: Update. * Credits: Update. 1998-07-29 Joseph S. Myers * NEWS: Update. * INSTALL: Update. * PACKAGING: New file - information for those packaging bsd-games for a Linux distribution. 1998-07-28 Joseph S. Myers * TODO: Update. * substfiles: Include hide-game (no need to special case it). * configure, Makefile: Don't special case hide-game. * hide-game.in: No longer needs #!/bin/sh, since added by configure. * install-score.in: Likewise. * install-man.in: Likewise. * caesar/rot13.in: Likewise. * configure (substitute): Put comments at the top of generated files saying they are automatically generated. 1998-07-27 Joseph S. Myers * All games (expect paranoia) now updated from NetBSD-current of 1998-07-27 (some of the Linux changes merged back to NetBSD). * snake/snscore/snscore.c: Update from NetBSD-current of 1998-07-27. * sail/dr_2.c, sail/extern.h: Update from NetBSD-current of 1998-07-27. * rogue/init.c, rogue/machdep.c, rogue/monster.c, rogue/rogue.h: Update from NetBSD-current of 1998-07-27. * robots/move.c: Update from NetBSD-current of 1998-07-27. * pom/pom.c: Update from NetBSD-current of 1998-07-27. * phantasia/phantglobs.c, phantasia/phantglobs.h: Update from NetBSD-current of 1998-07-27. * mille/mille.h, mille/misc.c: Update from NetBSD-current of 1998-07-27. * battlestar/dayfile.c, battlestar/nightfile.c: Update from NetBSD-current of 1998-07-27 (changes merged - this changes rcsids only). * atc/atc.6, atc/log.c: Update from NetBSD-current of 1998-07-27. * adventure/wizard.c: Update from NetBSD-current of 1998-07-27. * configure: Allow defaults to be taken from a config.params file, which can specify non-interactive operation. 1998-07-25 Joseph S. Myers * configure: Make a /bin/sh script; use printf instead of echo -n so that a POSIX.2 shell suffices. * INSTALL: Update. * TODO: Update. 1998-07-22 Joseph S. Myers * NEWS: Update. * rogue/machdep.c (md_gseed): Use time, not pid, as seed, so you don't get the same game each time if you boot the system up to play rogue (patch from Bill Lash ). * rogue/monster.c (mv_mons): If a dragon kills a monster on level_monsters, mv_mons can move things in the free_list, so don't move monsters not on level_monsters (patch from Bill Lash ). * All games (except paranoia) now updated from NetBSD-current of 1998-07-11. * worms/worms.6: Update from NetBSD-current of 1998-07-11. * sail/*: Update from NetBSD-current of 1998-07-11. * pom/*: Update from NetBSD-current of 1998-07-11. * hunt/*/*: Update from NetBSD-current of 1998-07-11. * dm/*: Update from NetBSD-current of 1998-07-11. 1998-07-21 Joseph S. Myers * countmail/countmail.6: Update from NetBSD-current of 1998-07-11. * boggle/*/Makefile.bsd: Update from NetBSD-current of 1998-07-11. * battlestar/extern.h: Update from NetBSD-current of 1998-07-11. * backgammon/backgammon/main.c: Update from NetBSD-current of 1998-07-11. * atc/*: Update from NetBSD-current of 1998-07-11. * atc/Makefile: Use grammar.h instead of y.tab.h. * arithmetic/arithmetic.6: Update from NetBSD-current of 1998-07-11. * quiz/datfiles/europe: Fix typo (patch from G. Branden Robinson ). * TODO: Update. * BUGS: Update. * README.non-free: Update. * YEAR2000: Minor changes. * README: Update. * INSTALL: Update. * Credits: Minor changes. 1998-07-20 Joseph S. Myers * YEAR2000: New file, year 2000 statement for bsd-games. * adventure/wizard.c (datime): Handle leap years correctly according to the Gregorian calendar (could be perceived as fixing a year 2000 problem, but it was broken wrt leap years anyway). * pom/pom.c (main): Add 1900 to year as argument of isleap() (fixes year 2000 problem). 1998-07-03 Joseph S. Myers * Credits: Add introductory paragraph. 1998-04-11 Joseph S. Myers * Makefile: Add some standard GNU makefile targets. 1998-04-07 Joseph S. Myers * configure: Update message before selecting pager. * wump/wump.c (instructions): Use POSIX.2 pager behaviour. * quiz/quiz.c (show_index): Use POSIX.2 pager behaviour. * fish/fish.c (instructions): Use POSIX.2 pager behaviour. 1998-04-06 Joseph S. Myers * cribbage/instr.c (instructions): Use POSIX.2 pager behaviour. 1998-04-04 Joseph S. Myers * BUGS: Update. * INSTALL: Update for changed paths. * configure: Change default paths to FHS ones; change some comments and messages. * bsd-games.lsm (Primary-site): Make sunsite, since tsx-11 is somewhat unreliable and laggardly about installing new releases. 1998-03-29 Joseph S. Myers * Version 2.1. * TODO: Update. * README: Update. * INSTALL: Update. * Credits: Update. 1998-03-28 Joseph S. Myers * boggle/README.linux: Rebuild. * bsd-games.lsm, bsd-games-non-free.lsm, NEWS: Update. * configure: Don't ask about libc version or BSD signal defines. * Makeconfig.in (BSD_SIGNAL_DEFS): Removed. * */Makefile, */*/Makefile, hunt/Makeconfig: Don't use $(BSD_SIGNAL_DEFS). * include/signal.h: Define __USE_BSD_SIGNAL if libc5, so that the Makefiles don't need to. * lib/fgetln.c: New file, implementation of fgetln() (from quiz/quiz.c). * include/stdio.h: New file, wrap and declare fgetln(). * quiz/quiz.c: Don't include implementation of fgetln(). 1998-03-27 Joseph S. Myers * dm/dm.c (load): Use getloadavg(). * dm/Makefile: Use getloadavg() from lib/getloadavg.c. * lib/getloadavg.c: New file, implementation of getloadavg(). * include/stdlib.h: New file, wrap and declare getloadavg(). * wump/wump.c (move_to, shoot): Add explicit braces to avoid ambiguous else. * trek/shield.c (shield): Add explicit braces to avoid ambiguous else. * trek/nova.c (nova): Add explicit braces to avoid ambiguous else. * trek/move.c (move): Add explicit braces to avoid ambiguous else. * trek/kill.c (killb): Add explicit braces to avoid ambiguous else. * sail/sync.c (sync_update): Add explicit braces to avoid ambiguous else. * sail/sync.c (Sync): Don't declare errno. * sail/dr_1.c (compcombat, next): Add explicit braces to avoid ambiguous else. * sail/pl_7.c (newturn): Add explicit braces to avoid ambiguous else. * sail/pl_3.c (acceptcombat): Add explicit braces to avoid ambiguous else. * phantasia/misc.c (tradingpost): Add explicit braces to avoid ambiguous else. * phantasia/fight.c (playerhits, awardtreasure): Add explicit braces to avoid ambiguous else. * phantasia/main.c (main): Add explicit braces to avoid ambiguous else. * fortune/fortune/fortune.6: Rename to fortune.6.in. * fortune/fortune/fortune.6.in: Parametrise. * substfiles: Include fortune/fortune/fortune.6. * monop/morg.c (set_mlist): Add explicit braces to avoid ambiguous else. * monop/cards.c (get_card): Add explicit braces to avoid ambiguous else. * hunt/hunt/hunt.c (list_drivers): Add explicit int in declaration of `initial'. (env_init): Add explicit braces to avoid ambiguous else. * fortune/fortune/fortune.c (display, form_file_list): Add explicit braces to avoid ambiguous else. (init_prob): Add braces to make if/else binding agree with the indentation. * cribbage/score.c (scorehand): Add explicit braces to avoid ambiguous else. * cribbage/crib.c (peg): Add explicit braces to avoid ambiguous else. * boggle/boggle/bog.c (main): Add explicit braces to avoid ambiguous else. * battlestar/com5.c (love): Add explicit braces to avoid ambiguous else. * atc/input.c (delayb, benum): Change char to unsigned char for subscript. * Credits: Update. * paranoia/paranoia.6: New manpage, from Joey Hess. * paranoia/Makefile: Install it. * wargames/wargames.6: New manpage, from Joey Hess . * wargames/Makefile: Install it. * hunt/Makefile.inc.bsd, hunt/hunt/Makefile.bsd, hunt/huntd/bsd.h, hunt/huntd/hunt.h, hunt/huntd/huntd.6.in, hunt/huntd/talk_ctl.h: Update from NetBSD-current of 1998-03-21. * fortune/*: Update from NetBSD-current of 1998-03-21. * fortune/fortune/Makefile: Use -DHAVE_REGCOMP. * Makefile.inc.bsd, adventure/init.c, atc/Makefile.bsd, backgammon/Makefile.inc.bsd, battlestar/Makefile.bsd, battlestar/extern.h, boggle/*/Makefile.bsd, caesar/caesar.6, canfield/*/Makefile.bsd, cribbage/Makefile.bsd, dm/Makefile.bsd, dm/dm.c, factor/Makefile.bsd, fish/fish.c, rain/Makefile.bsd, robots/Makefile.bsd, rogue/Makefile.bsd, sail/Makefile.bsd, snake/*/Makefile.bsd, tetris/Makefile.bsd, worm/Makefile.bsd, worms/Makefile.bsd, gomoku/Makefile.bsd, gomoku/main.c, hangman/Makefile.bsd, mille/Makefile.bsd, phantasia/Makefile.bsd, phantasia/setup.c, quiz/datfiles/pres: Update from NetBSD-current of 1998-03-21. 1998-03-26 Joseph S. Myers * monop/monop.c (main): Use SIGINT instead of 2 in signal. * backgammon/teachgammon/teach.c (main): Use SIGINT instead of 2 in signal. * backgammon/backgammon/main.c (main): Use SIGINT instead of 2 in signal, and 14 instead of SIGALRM. * BUGS: New file, lists known bugs. * INSTALL, README, TODO: Update. * trek/dumpgame.c (restartgame): Use O_RDONLY instead of 0 in open. * monop/execute.c (rest_f): Use O_RDONLY instead of 0 in open. * fortune/fortune/fortune.c (add_file, all_forts, open_dat, get_pos, get_tbl): Use O_RDONLY instead of 0 in open. * canfield/cfscores/cfscores.c (main): Use O_RDONLY instead of 0 in open. * canfield/canfield/canfield.c (initall): Use O_RDWR instead of 2 in open. * quiz/datfiles/europe: Added more new countries. 1998-03-25 Joseph S. Myers * quiz/datfiles/europe: Update for political changes of the 1990s (needs more work). * Credits: Update. * INSTALL, README: Update (need libc 5.4.5 or later if using libc5). 1998-01-02 Joseph S. Myers * battlestar/battlestar.c, battlestar/init.c, battlestar/save.c, battlestar/extern.h, battlestar/cypher.c, battlestar/battlerstar.6: Let save file name vary. 1997-12-30 Joseph S. Myers * battlestar/com5.c (give): The value 0 used in NetBSD is as good as any for initialising last1 and last2, so use it; check for it in last1 at the appropriate place and give an error if so. * battlestar/com3.c (shoot): Correct initialiser for firstnumber is always wordnumber. 1997-12-29 Joseph S. Myers * mille/mille.h, mille/varpush.c: Make previous change conditional on defined(__linux__) && !defined(__GLIBC__), since the X/Open spec says you should use int but libc5 (only) uses size_t. * boggle/boggle/help.c (help): Use redrawwin(stdscr) at the end, to get proper redrawing with ncurses. * boggle/README.linux: Rebuild. * Makeconfig.in (DEFS_TO_PASS, DEFS_TO_PASS_STRIP): New variables, definitions of installation variables to pass to sub-makes. * Makefile (install, install-strip): Use these. * configure (strip_install): Remove configuration option. * INSTALL: Update. * backgammon/Makefile, boggle/Makefile, canfield/Makefile, fortune/Makefile, hunt/Makefile, snake/Makefile: Pass DEFS_TO_PASS in install. 1997-12-26 Joseph S. Myers * mille/mille.h: prscore's argument is bool, not int (from Joey Hess). 1997-12-25 Joseph S. Myers * Version 2.0. * INSTALL: Add name and email address to bottom. * Credits: Update. Sun Dec 21 11:59:34 1997 Joseph S. Myers * configure: Don't ask for file for backgammon rules. * TODO: Update. * Makefile (install): Don't create $(SOCKETDIR), which is no longer defined. * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. * README: Update. * configure: Don't configure bsd_lib or bsd_includes. * Makeconfig.in: Delete BSD_LIB, BSD_INCS, BSD_DEFS. * configure (warning_flags): Default to -Wall -W -Wstrict-prototypes -Wmissing-prototypes. Sat Dec 20 11:25:48 1997 Joseph S. Myers * All games (except paranoia) now updated to NetBSD-current of 1997-12-12. * wump/wump.c: Include . * wump/*: Update from NetBSD-current of 1997-12-12. * wump/Makefile: Use -I../include; don't define path; don't use libbsd or ncurses. * substfiles: Include wump/pathnames.h. * worms/worms.c (onsig): Mark unused parameter. * worms/*: Update from NetBSD-current of 1997-12-12. * worms/Makefile: Use -I../include; use BSD signal defines only. * worm/worm.c: Mark unused parameters. * worm/worm.6: Fix. * worm/*: Update from NetBSD-current of 1997-12-12. * worm/Makefile: Use -I../include; use BSD signal defines only. * trek/warp.c (dowarp): Mark parameter as int. * trek/abandon.c, trek/capture.c, trek/computer.c, trek/dcrept.c, trek/destruct.c, trek/dock.c, trek/dumpgame.c, trek/help.c, trek/impulse.c, trek/lrscan.c, trek/phaser.c, trek/play.c, trek/rest.c, trek/setwarp.c, trek/torped.c, trek/visual.c, trek/cgetc.c: Mark unused parameters. * trek/*: Update from NetBSD-current of 1997-12-12. * trek/Makefile: Use -I../include; don't use libbsd. * tetris/tetris.c: Mark unused parameter. * tetris/scores.c: Fix warnings. * tetris/screen.c, tetris/screen.h: Make put return int. * tetris/screen.c: Don't declare ospeed. * tetris/*: Update from NetBSD-current of 1997-12-12. * tetris/Makefile: Use -I../include; don't define paths; use BSD signal defines only. * substfiles: Include tetris/pathnames.h. * snake/snake/snake.c, snake/snscore/snscore.c: Mark unused parameters. * snake/snake/snake.h, snake/snake/move.c: Make outch return int. * snake/snake/snake.h, snake/snake/move.c: Don't declare ospeed. * snake/*: Update from NetBSD-current of 1997-12-12. * snake/snake/Makefile, snake/snscore/Makefile: Use -I../../include; don't define paths; use BSD signal defines only. * substfiles: Include snake/snake/pathnames.h. * sail/pl_main.c, sail/pl_7.c, sail/player.h: Move screen initialisation into initscreen(); no longer do echo() in SCREENTEST(). * sail/sync.c: Include and ; mark int parameter. * sail/misc.c: Include , for flock(). * sail/game.c: Fix pointer/integer comparison warning. * sail/dr_2.c: Mark int parameters as such. * sail/player.h (SCREENTEST): Compare initscr() against NULL, not ERR. * sail/main.c, sail/pl_1.c, sail/pl_7.c: Mark unused parameters. * sail/dr_2.c, sail/extern.h: Rename move to sail_move. * sail/*: Update from NetBSD-current of 1997-12-12. * sail/Makefile: Use -I../include; don't define paths; use BSD signal defines only. * substfiles: Include sail/pathnames.h * rogue/save.c: Fix signed/unsigned warnings. * rogue/monster.c, rogue/object.c, rogue/pack.c, rogue/room.c: Mark int parameters as such. * rogue/init.c: Mark unused parameters. * rogue/*: Update from NetBSD-current of 1997-12-12. * rogue/Makefile: Use -I../include; don't define path; use BSD signal defines only. * substfiles: Include rogue/pathnames.h. * robots/move.c (get_move): Always initialise lastmove, to shut up gcc. * robots/main.c: Remove unused function __cputchar; mark unused parameter. * robots/move.c (get_move): Restore declaration of lastmove. * robots/*: Update from NetBSD-current of 1997-12-12. * robots/Makefile: Use -I../include; don't define path; use BSD signal defines only. * substfiles: Include robots/pathnames.h. * Credits: List original authors. * bsd-games.lsm: Update. * NEWS: Update. * INSTALL: Update. * README.non-free: Update. * README: Update. * countmail/*: New game, from NetBSD-current of 1997-12-12. * configure (install_script): New variable, avoid warnings about stripping scripts. * Makeconfig.in (INSTALL_SCRIPT): Define. * caesar/Makefile, wargames/Makefile: Use $(INSTALL_SCRIPT). Fri Dec 19 14:37:56 1997 Joseph S. Myers * TODO: Update. * hunt/*: New port, replacing the old one, based on NetBSD-current of 1997-12-12. * substfiles: Update accordingly. * configure, Makeconfig.in: No longer need to configure directory for sockets. * random/*: Update from NetBSD-current of 1997-12-12. * random/Makefile: Use -I../include. * rain/rain.c: Make fputchar return int, since this is what tputs expects. Also mark unused parameters. * rain/*: Update from NetBSD-current of 1997-12-12. * rain/Makefile: Use -I../include; don't use libbsd. * substfiles: Don't include rain/rain.6. * quiz/quiz.c (appdstr): Change NULL to '\0' to fix warning. * quiz/*: Update from NetBSD-current of 1997-12-12. * quiz/Makefile: Use -I../include; don't define paths. * substfiles: Include quiz/pathnames.h.in. * primes/*: Update from NetBSD-current of 1997-12-12. * primes/Makefile: Use -I../include. * include/sys/ttydefaults.h: New file, wrap so that individual games need not know that it is in glibc but not libc5. * hangman/getguess.c: Restore to NetBSD version since these conditionals are no longer needed. * lib/select.c: New file, emulate BSD select for games that need it (I think only hunt), so that libbsd will not be needed at all and games will work fine with libc6. Thu Dec 18 13:24:54 1997 Joseph S. Myers * ppt/*: Update from NetBSD-current of 1997-12-12. * ppt/Makefile: Use -I../include. * pom/pom.c: Mark unused parameters. * pom/*: Update from NetBSD-current of 1997-12-12. * pom/Makefile: Use -I../include; don't use libbsd. * include/tzfile.h: New file. * pig/pig.c (main): Fix signed/unsigned warning. * pig/*: Update from NetBSD-current of 1997-12-12. * pig/Makefile: Use -I../include. * phantasia/setup.c: Include ; fix warnings; add prototypes and function return types. * phantasia/interplayer.c (dotampered): Avoid signed/unsigned warning. * phantasia/io.c (catchalarm): Mark unused parameter. * phantasia/*: Update from NetBSD-current of 1997-12-12. * phantasia/Makefile: Don't define paths; use BSD signal defines only. * substfiles: Include phantasia/pathnames.h. * paranoia/paranoia.c: Include headers, add prototypes and function return types; changes to avoid warnings. * number/*: Update from NetBSD-current of 1997-12-12. * number/Makefile: Use -I../include. * morse/*: Update from NetBSD-current of 1997-12-12. * morse/Makefile: Use -I../include. * monop/cards.c: Avoid signed/unsigned warning. * monop/monop.c (do_quit): Mark unused parameter. * monop/*: Update from NetBSD-current of 1997-12-12. * monop/Makefile: Use -I../include; don't define path; use BSD signal defines only. * substfiles: Include monop/pathnames.h. * NEWS: Update; fix typo. * mille/save.c: Include . * mille/mille.h, varpush.c: Use size_t for last argument of last argument of varpush. * mille/comp.c (calcmove): Avoid signed/unsigned warning. * mille/mille.c (rub): Mark unused parameter. * mille/*: Update from NetBSD-current of 1997-12-12. * mille/Makefile: Use -I../include; don't use libbsd. * substfiles: Don't include mille/mille.6, it's no longer needed. * hangman/setup.c: Include . * hangman/main.c: Mark unused parameters. * hangman/*: Update from NetBSD-current of 1997-12-12. * hangman/Makefile: Use -I../include; don't define path; don't use libbsd. * substfiles: Include hangman/pathnames.h. Wed Dec 17 16:14:21 1997 Joseph S. Myers * gomoku/pickmove.c: Fix signed/unsigned warnings; mark unused parameter. * gomoku/main.c: Include ; mark unused parameter. * gomoku/*: Update from NetBSD-current of 1997-12-12. * gomoku/Makefile: Use -I../include; use BSD signal defines only. * fortune/strfile/strfile.c, fortune/fortune/fortune.c, fortune/unstr/unstr.c: Changes to avoid warnings. * fortune/*: Update from NetBSD-current of 1997-12-12. * fortune/fortune/Makefile, fortune/strfile/Makefile, fortune/unstr/Makefile: Use -I../../include; don't use libbsd; don't define paths. * substfiles: Include fortune/fortune/pathnames.h. * fish/*: Update from NetBSD-current of 1997-12-12. * fish/Makefile: Use -I../include. * substfiles: Include fish/pathnames.h. * primes/pr_tbl.c: Use __RCSID. * factor/*: Update from NetBSD_current of 1997-12-12. * factor/Makefile: Use -I../include. * Makeconfig.in: Remove dm variables. * dm/dm.c: Mark unused parameter. * dm/pathnames.h.in: Undefine _PATH_LOG before defining it. * dm/dm.8.in: Fix. * dm/*: Update from NetBSD-current of 1997-12-12. * dm/Makefile: Use -I../include; don't define paths. * substfiles: Include dm/pathnames.h. Tue Dec 16 10:35:32 1997 Joseph S. Myers * cribbage/io.c, cribbage/score.c: Avoid signed/unsigned warning; mark unused parameters. * cribbage/*: Update from NetBSD-current of 1997-12-12. * cribbage/Makefile: Use -I../include; don't use libbsd or define paths. * substfiles: Include cribbage/pathnames.h. * canfield/canfield/canfield.c: Include ; mark unused parameters. * canfield/*: Update from NetBSD-current of 1997-12-12. * canfield/canfield/Makefile, canfield/cfscores/Makefile: Use -I../../include. * substfiles: Include canfield/canfield/pathnames.h. * canfield/canfield/Makefile, canfield/cfscores/Makefile: Don't define _PATH_SCORE; don't use libbsd. * caesar/*: Update from NetBSD-current of 1997-12-12. * caesar/Makefile: Use -I../include. * caesar/rot13.in: Use "$@" instead of $*. * boggle/boggle/mach.c: Mark unused parameters. * boggle/boggle/bog.c: Changes to avoid warnings. * boggle/mkindex/mkindex.c (main): Make it take no arguments, since they are unused. * boggle/mkdict/mkdict.c: Include ; other changes to avoid warnings. * boggle/*: Update from NetBSD-current of 1997-12-12. * boggle/boggle/Makefile, boggle/mkdict/Makefile, boggle/mkindex/Makefile: Use -I../../include. * substfiles: Include boggle/boggle/bog.h. * boggle/boggle/Makefile: Don't define paths. * boggle/Makefile, boggle/README.linux: Update for change to bog.h.in. * bcd/bcd.6: Fix. * bcd/*: Update from NetBSD-current of 1997-12-12. * bcd/Makefile: Use -I../include. * battlestar/battlestar.6: Fix typo. * battlestar/com6.c, battlestar/fly.c: Mark unused parameters. * battlestar/*: Update from NetBSD-current of 1997-12-12. * battlestar/Makefile: Use -I../include, and BSD signal defines only. * substfiles: Include battlestar/pathnames.h. * battlestar/Makefile: Don't define _PATH_SCORE. Mon Dec 15 10:07:10 1997 Joseph S. Myers * banner/Makefile: Use -I../include. * banner/*: Update from NetBSD-current of 1997-12-12. * TODO: Update. * backgammon/common_source/subs.c (getarg): Check that an argument is given to -s. * backgammon/common_source/subs.c, backgammon/backgammon/main.c, backgammon/teachgammon/teach.c: Mark unused parameters. * backgammon/common_source/subs.c (addbuf): Make addbuf return an int, since this is what tputs expects. * backgammon/common_source/back.h: Likewise. * backgammon/teachgammon/teach.c: Don't declare ospeed. * backgammon/backgammon/main.c: Don't declare ospeed; include . * backgammon/backgammon/Makefile, backgammon/common_source/Makefile, backgammon/teachgammon/Makefile: Use -I../../include. * Makeconfig.in (BACKGAMMON_RULES): Remove. * backgammon/*: Update from NetBSD-current of 1997-12-12; make changes for no longer having simple game. * atc/pathnames.h: Remove. * atc/pathnames.h.in: New file, from NetBSD-current and parametrised. * substfiles: Substitute in this file. * atc/Makefile: Don't define _PATH_GAMES and _PATH_SCORE any more. * substfiles: New file - list of files created by substitution. * configure, Makefile: Use this list. * atc/log.c (log_score): Use nodename, not sysname. * atc/grammar.y, atc/graphics.c, atc/log.c, atc/main.c, atc/update.c: Mark unused parameters and add parameter types. * atc/Makefile: Use -I../include and -DYY_NO_UNPUT. * atc/*: Update from NetBSD-current of 1997-12-12. * adventure/setup.c: Use __RCSID and __COPYRIGHT. * include/sys/cdefs.h: Mark rcsid and copyright unused, so -Dlint is not needed when using warnings. * arithmetic/arithmetic.c (intr): Mark `dummy' unused. * arithmetic/Makefile: Use -I../include. * arithmetic/*: Update from NetBSD-current of 1997-12-12. * adventure/init.c, adventure/subr.c, adventure/wizard.c: Add argument types and mark unused arguments as __attribute__((unused)). * adventure/crc.c: Make step unsigned int. * adventure/setup.c: Add prototype; include . * adventure/extern.h: Remove prototypes for setup.c. * adventure/Makefile: Use -I../include. * adventure/*: Update from NetBSD-current of 1997-12-12. * include/signal.h: New file, wrapper to typedef sig_t without needing for libc5. * include/sys/cdefs.h: New file, wrapper to define __RCSID and __COPYRIGHT. * Makefile.bsd, Makefile.inc.bsd: Update from NetBSD-current of 1997-12-12. Wed Sep 24 13:44:06 1997 Joseph S. Myers * caesar/caesar.c: Include and ; add prototypes and function return types; remove old declarations. * boggle/boggle/mach.c (winch_catcher): Don't ioctl(TIOCGWINSZ). * boggle/boggle/bog.c: Add prototypes. * boggle/mkdict/mkdict.c: Add prototypes. * boggle/mkindex/mkindex.c: Add prototypes; include . * boggle/README.linux: Update. * INSTALL: Update. * README: Update. * README.non-free: Update. * TODO: Update. * bsd-games-non-free.lsm: Update. * Makeconfig.in: Update. * configure: Use boggle instead of bog; don't substitute in bog.6.in. * Makefile: Don't remove bog/bog.6. * boggle/boggle/extern.h: Include (for time_t). * boggle/boggle/Makefile: Use BSD signal defines only. * boggle/*: From NetBSD-current; merge in Linux changes from bog. * atc/log.c, atc/update.c: Consistently use strchr and strrchr. * atc/include.h [SYSV]: Remove #defines of index and rindex. * bcd/bcd.c (printcard): Remove declaration of index(); use strchr(); make p unsigned char. * bcd/bcd.c: Include . * bcd/bcd.c: Add prototypes and function return types. Sat Sep 13 21:08:53 1997 Joseph S. Myers * configure: Fix spelling errors; some cleanup. Tue Sep 2 17:28:22 1997 Joseph S. Myers * configure: Use empty man8dir if not building in dm or fortune. Sun Aug 24 10:33:08 1997 Joseph S. Myers * adventure/*: Update from NetBSD-current of 1997-08-24. * adventure/Makefile: Add dependency on extern.h. * adventure/Makefile: Add definitions of __RCSID and __COPYRIGHT. * fortune/*: Update from NetBSD-current of 1997-08-24. * battlestar/fly.c: Include . * battlestar/fly.c (visual): Remove declaration of moveenemy(). * battlestar/save.c (restore): Remove declaration of getenv(). (save): Likewise. * battlestar/getcom.c: Include "extern.h" for prototypes. * battlestar/init.c: Include . * battlestar/init.c (initialize): Remove declaration of die(). * battlestar/com6.c (post): Remove declaration of ctime(). * battlestar/com1.c: Include (for sleep). * battlestar/com1.c (convert): Make i and j unsigned to avoid warnings for comparison with unsigned. * battlestar/com4.c (throw): Make n unsigned for the save reason. * battlestar/extern.h, battlestar/parse.c, battlestar/room.c, battlestar/save.c: Add prototypes and function return types. Sat Aug 23 21:17:20 1997 Joseph S. Myers * battlestar/battlestar.c, battlestar/com1.c, battlestar/com2.c, battlestar/com3.c, battlestar/com4.c, battlestar/com5.c, battlestar/com6.c, battlestar/com7.c, battlestar/cypher.c, battlestar/extern.h, battlestar/fly.c, battlestar/getcom.c, battlestar/init.c, battlestar/misc.c: Add prototypes and function return types. * battlestar/extern.h: Don't conditionalise inclusion of . Mon Aug 18 09:14:17 1997 Joseph S. Myers * banner/banner.c: Add prototype for main(). * backgammon/common_source/Makefile, backgammon/backgammon/Makefile, backgammon/teachgammon/Makefile: Use BSD signal defines only. * atc/include.h: Include (for umask). * atc/Makefile: Use BSD signal defines only. * adventure/Makefile: Don't use BSD includes, defines or library (works with SYSV signal semantics as well). * configure: Ask for libc version; configure defines for BSD signal semantics (-D__USE_BSD_SIGNAL, etc.). * Makeconfig.in (BSD_SIGNAL_DEFS): New variable. * backgammon/common_source/Makefile (clean): Remove sbackgammon. * backgammon/common_source/fancy.c: Include . * backgammon/common_source/subs.c: Include . * backgammon/common_source/save.c: Include . * backgammon/common_source/fancy.c: Include . * backgammon/common_source/allow.c, backgammon/common_source/back.h, backgammon/common_source/board.c, backgammon/common_source/check.c, backgammon/common_source/fancy.c, backgammon/common_source/odds.c, backgammon/common_source/one.c, backgammon/common_source/save.c, backgammon/common_source/subs.c, backgammon/common_source/table.c: Add prototypes and function return types. Sun Aug 10 10:06:10 1997 Joseph S. Myers * atc/main.c (main): Include program name in `Unknown option' error message. * atc/include.h: Include . * atc/extern.h, atc/graphics.c, atc/input.c, atc/list.c, atc/log.c, atc/main.c, atc/update.c: Add prototypes and function return types. Sat Aug 9 16:36:17 1997 Joseph S. Myers * atc/extern.h, atc/grammar.y, atc/graphics.c, atc/input/c, atc/update.c: Add prototypes and function return types. Thu Aug 7 12:01:56 1997 Joseph S. Myers * atc/include.h: Make inclusion of unconditional; remove unused defines of bcopy and bzero under SYSV. * configure: Escape ` and ' when asking for .so or symlinks. * configure, Makeconfig.in, atc/Makefile: Configure yacc and lex programs using configure script. * configure: Add note about placing of sockets. * dm/README.linux: New file, mentions -DLOG. * configure, Makeconfig.in, dm/Makefile: Configure log file for dm. Sun Jul 27 12:45:18 1997 Joseph S. Myers * arithmetic/arithmetic.c: Include and ; add function return types and prototypes; remove previous function declarations. Sat Jul 26 20:17:49 1997 Joseph S. Myers * adventure/crc.c: Add prototypes. * adventure/setup.c (main): Add casts so as not to print a long with an int format. * adventure/io.c, adventure/setup.c: Add prototypes and function return types. Fri Jul 25 12:48:04 1997 Joseph S. Myers * adventure/wizard.c: Include ; remove declaration of localtime(). * adventure/setup.c: Include . * adventure/subr.c, adventure/wizard.c: Add some prototypes. * adventure/save.c: Include . * adventure/crc.c, adventure/io.c, adventure/save.c, adventure/vocab.c, adventure/wizard.c: Add function return types. * adventure/hdr.h: More prototypes. * adventure/wizard.c (ran): Remove declaration of rand(). * adventure/hdr.h, adventure/init.c, adventure/wizard.c: Change macro DECR and all uses so as not to need -traditional-cpp * adventure/Makefile: Don't use -traditional-cpp. Thu Jul 24 19:30:35 1997 Joseph S. Myers * adventure/init.c: Include and ; remove declaration of time(). * adventure/init.c: Add argument to trapdel(); add prototype for linkdata(). * adventure/main.c (main): Remove declaration of trapdel(). * adventure/main.c: Add prototype for main(). * adventure/hdr.h, adventure/main.c, adventure/save.c, adventure/vocab.c: Change link to adv_link. * adventure/main.c: Include . * adventure/io.c: Include . * adventure/wizard.c: Include and . * adventure/vocab.c: Include and . * adventure/subr.c: Include and . * adventure/done.c: Include and . * adventure/done.c, adventure/init.c, adventure/io.c, adventure/save.c, adventure/subr.c, adventure/vocab.c, adventure/wizard.c: Add function return types. * adventure/hdr.h: Add prototypes; remove declaration of malloc(). Sat Jul 19 20:51:49 1997 Joseph S. Myers * configure: Set empty man5dir if not building in dm. Thu Jul 17 16:41:29 1997 Joseph S. Myers * Version 1.5. * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. Wed Jul 16 12:50:00 1997 Joseph S. Myers * bsd-games.lsm: Update. * NEWS: Update. * Makefile (install): Create MAN5DIR. * NEWS: Update. * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. Tue Jul 15 15:57:06 1997 Joseph S. Myers * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. * TODO: Update. * README.non-free: Update. * README: Update. * INSTALL: Update. * rogue/machdep.c (md_slurp): Use tcflush() under Linux. * rogue/Makefile (DEFS): Add UNIX_SYSV to get included in machdep.c. * rogue/*: Added from NetBSD-current. * rogue/Makefile: Renamed to Makefile.bsd. * rogue/USD.doc/Makefile: Renamed to Makefile.bsd. * rogue/Makefile: New file. * rogue/rogue.6: Rename to rogue.6.in. * rogue/rogue.6.in: Parametrise. * configure: Ask for rogue scorefile; substitute in this file. * Makefile: Remove rogue.6 in distclean. * Makeconfig.in: Include ROGUE_SCOREFILE. * rogue/pathnames.h: The path for the score file is in the Makefile. Mon Jul 14 11:46:56 1997 Joseph S. Myers * quiz/Makefile (clean): Add target. * random/*: Added from NetBSD-current. * random/Makefile: Renamed to Makefile.bsd. * random/Makefile: New file. * quiz/quiz.c (fgetln): Add implementation since Linux libc lacks fgetln. * quiz/*: Added from NetBSD-current. * quiz/Makefile: Renamed to Makefile.bsd. * quiz/Makefile: New file. * quiz/datfiles/index: Rename to index.in. * quiz/datfiles/index.in: Parametrise. * quiz/quiz.6: Rename to quiz.6.in. * quiz/quiz.6.in: Parametrise. * configure: Ask for quiz directory; substitute in these files. * Makeconfig.in (QUIZ_DIR): Add for quiz directory. * Makefile: Remove index and quiz.6 in distclean. * quiz/pathnames.h: Paths are defined in the Makefile. * pig/*: Added from NetBSD-current. * pig/Makefile: Renamed to Makefile.bsd. * pig/Makefile: New file. * phantasia/main.c (playinit): Add ICRNL to terminal modes if using ncurses. * phantasia/Makefile (install): Bug-fix. * configure: Configure directory for phantasia. * Makeconfig.in: Include PHANTASIA_DIR. * phantasia/pathnames.h: Paths are defined in Makefile. * phantasia/Makefile: Supply motd to setup. Sun Jul 13 18:28:52 1997 Joseph S. Myers * phantasia/*: Added from NetBSD-current. * phantasia/Makefile: Renamed to Makefile.bsd. * phantasia/Makefile: New file. * dm/dm.c (load): Add Linux-specific way of getting load average. * dm/dm.8: Rename to dm.8.in. * dm/dm.conf.5: Rename to dm.conf.5.in. * dm/dm.8.in, dm/dm.conf.5.in: Parametrise. * configure: Substitute in these files. * Makefile: Remove dm.8 and dm.conf.5 in distclean. * configure: Do additional configuration for dm. * Makeconfig.in: Include these variables. * install-man.in: Allow manual section 5. * dm/*: Added from NetBSD-current. * dm/Makefile: Renamed to Makefile.bsd. * dm/Makefile: New file. * TODO: Update. * All games, except bog, hunt, and paranoia, now updated from NetBSD-current of 1997-07-12. * cribbage/*: Update from NetBSD-current of 1997-07-12. Fri Jul 11 19:09:24 1997 Joseph S. Myers * bog/README.linux: Comply with licence conditions by including patch from original bog. * bog/Makefile (linux-patch): Create or update this patch. * banner/*: Added from NetBSD-current. * banner/Makefile: Renamed to Makefile.bsd. * banner/Makefile: New file. * atc/graphics.c (getAChar): Use SYSV method instead of BSD one under Linux; change conditional on inclusion of to allow for this. Thu Jun 12 20:32:57 1997 Joseph S. Myers * adventure/*: Added from NetBSD-current. * adventure/Makefile: Renamed to Makefile.bsd. * adventure/Makefile: New file. Wed Jun 11 12:09:38 1997 Joseph S. Myers * Now builds with glibc without needing stray headers. * snake/snake/snake.c: Define MIN instead of including . * pom/pom.c: With glibc, define isleap instead of including . * mille/Makefile: Remove dependency on unctrl.h. * configure: Choose default for BSD-compat includes based on whether /usr/include/bsd exists. Tue Jun 10 17:40:44 1997 Joseph S. Myers * All games, with same exceptions as below, now updated from NetBSD-current of 1997-06-07. * cribbage/*, hangman/*, mille/*, robots/*, tetris/*: Update from NetBSD-current of 1997-06-07. Fri Jun 6 22:19:38 1997 Joseph S. Myers * README: Update. * *.orig, */*.orig, */*/*.orig: Rename to *.bsd instead to avoid conflicts with patch backups. Thu May 22 00:03:59 1997 Joseph S. Myers * TODO: Update. * README.non-free: Update. * README: Update. Wed May 21 00:08:36 1997 Joseph S. Myers * TODO: Update. * README: Update. * INSTALL: Update. * Now builds with glibc. * bog/mach.c (flushin): Use the flushinp() version. * cribbage/extern.c: Change `bool' to `BOOLEAN'. * atc/Makefile: Use -lfl instead of -ll. Tue May 20 00:26:52 1997 Joseph S. Myers * All games, with same exceptions as below, now updated from NetBSD-current of 1997-05-17. * backgammon/backgammon/Makefile.orig, backgammon/teachgammon/Makefile.orig, factor/Makefile.orig, fortune/Makefile.orig, fortune/datfiles/Makefile.orig, fortune/strfile/Makefile.orig, wargames/Makefile.orig: Update from NetBSD-current of 1997-05-17. Mon May 19 00:50:37 1997 Joseph S. Myers * All games, except bog, hunt and paranoia, now updated from NetBSD-current of 1997-04-26. * wump/*: Update from NetBSD-current of 1997-04-26. * worms/Makefile (DEFS): Remove -DUSG which is no longer needed. * worms/*: Update from NetBSD-current of 1997-04-26. * worm/worm.c (process): Move the move to highlight head of worm here from main(). * worm/*: Update from NetBSD-current of 1997-04-26. * wargames/*: Update from NetBSD-current of 1997-04-26. Sun May 18 01:29:05 1997 Joseph S. Myers * trek/README.linux: New file, mentions trek manual. * trek/*: Update from NetBSD-current of 1997-04-26. * tetris/screen.c (OXTABS): Define to XTABS. * tetris/*: Update from NetBSD-current of 1997-04-26. Sat May 17 12:24:07 1997 Joseph S. Myers * snake/snake/snake.c: Define CTRL. * snake/snake/move.c: Include ; condition use of VDSUSP on its being defined; define CTRL; define OXTABS. * snake/*: Update from NetBSD-current of 1997-04-26. * sail/pl_7.c: Don't include . * sail/Makefile: Change dependency on externs.h to extern.h. * sail/*: Update from NetBSD-current of 1997-04-26. Thu May 15 15:09:59 1997 Joseph S. Myers * robots/move.c: Don't include ; define CTRL. * robots/*: Update from NetBSD-current of 1997-04-26. * hangman/getguess.c: Fix sense of glibc test for . * rain/rain.6: Rename to rain.6.in. * rain/rain.6.in: Parametrise. * configure: Substitute in this file. * Makefile: Remove rain/rain.6 in distclean. * rain/Makefile (DEFS): Remove -DUSG, as it's no longer needed. * rain/*: Update from NetBSD-current of 1997-04-26. Wed May 14 23:27:32 1997 Joseph S. Myers * primes/*: Update from NetBSD-current of 1997-04-26. * ppt/*: Update from NetBSD-current of 1997-04-26. * pom/*: Update from NetBSD-current of 1997-04-26. * number/*: Update from NetBSD-current of 1997-04-26. * morse/*: Update from NetBSD-current of 1997-04-26. * monop/*: Update from NetBSD-current of 1997-04-26. Mon May 12 02:08:53 1997 Joseph S. Myers * mille/misc.c (CTRL): Define. * mille/*: Update from NetBSD-current of 1997-04-26. Wed May 7 00:15:09 1997 Joseph S. Myers * Version 1.4. * Makefile, caesar/Makefile: Disable test in caesar (as it depends on rot13ed fortunes). * NEWS: Update. * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. * hangman/getguess.c (readch): Change curx to _curx, cury to _cury if using ncurses. * hangman/getguess.c: Don't include ; define CTRL. * hangman/*: Update from NetBSD-current of 1997-04-26. * fortune/README.linux: Update. * fortune/datfiles/Makefile: Update for more fortune collections. * configure: Ask whether to install offensive fortunes. * Makeconfig.in: Provide FORTUNE_TYPE. * fortune/*: Update from NetBSD-current of 1997-04-26. Tue May 6 00:53:04 1997 Joseph S. Myers * fish/*: Update from NetBSD-current of 1997-04-26. * Version 1.3.4beta. * NEWS: Update. * bsd-games-non-free.lsm: Update. * bsd-games.lsm: Update. * README: Update. * configure, tetris/Makefile: Consistently use tetris-bsd for files associated with tetris. * INSTALL: Update. * factor/*: Update from NetBSD-current of 1997-04-26. * cribbage/*: Update from NetBSD-current of 1997-04-26. Mon May 5 02:23:05 1997 Joseph S. Myers * canfield/*: Update from NetBSD-current of 1997-04-26. * caesar/caesar.6: Mention rot13. * caesar/Makefile: Install rot13 and manpage link. * caesar/rot13.sh: Rename to rot13.in. * caesar/rot13.in: Parametrise to use full path of caesar. * configure: Substitute in this file. * Makefile: Remove rot13 in distclean. * caesar/*: Update from NetBSD-current of 1997-04-26. * bcd/*: Update from NetBSD-current of 1997-04-26. * battlestar/com6.c (post): Change to use time() in line with comments. * battlestar/Makefile: Change dependency on externs.h to extern.h. * battlestar/*: Update from NetBSD-current of 1997-04-26. * backgammon/common_source/Makefile: Quote value of RULES; only define when building sbackgammon. * backgammon/backgammon/Makefile, backgammon/teachgammon/Makefile: Don't include RULES in DEFS. * backgammon/Makefile: Don't include ../Makeconfig. * backgammon/common_source/back.h (OXTABS): Define to XTABS if not defined (from glibc headers). * backgammon/*: Update from NetBSD-current of 1997-04-26. Sun May 4 01:55:22 1997 Joseph S. Myers * backgammon/common_source/subs.c: Initialise `buffnum' to -1, to prevent a spurious NUL. * backgammon/common_source/fancy.c: Mark `buffnum' as `extern'. Sat May 3 00:27:49 1997 Joseph S. Myers * Version 1.3.3beta. * NEWS: Update. * bsd-games.lsm: Update. * bsd-games-non-free.lsm: Update. * sail/player.h (SCREENTEST): Do echo(), since ncurses turns off echo in initscr but we want it on for initial questions. * backgammon/teachgammon/ttext1.c: Remove \032 from `hello'. * backgammon/teachgammon/ttext2.c: Make list `char *list[]'. * configure: Default list of directories should only include those with a Makefile. * README.non-free: Update. * README: Update. * INSTALL: Update. * Version 1.3.2beta. * NEWS: Update. * TODO: Update. * Makefile.orig, Makefile.inc.orig: Update from NetBSD-current of 1997-04-26. * Makefile (distclean): Remove install-score. Fri May 2 13:23:28 1997 Joseph S. Myers * atc/*: Update from NetBSD-current of 1997-04-26. * arithmetic/*: Update from NetBSD-current of 1997-04-26. * worm/worm.c (main): Place cursor on head of worm. * snake/snake/snake.c (mainloop): Place cursor on you, not one cell to the left and above. * backgammon/common_source/init.c, backgammon/common_source/back.h: Initialise args to start with '-'. * bsd-games-non-free.lsm: New file - LSM entry for bsd-games-non-free. * bsd-games.lsm: Update. * INSTALL: Update. * README.linux: Rename to README. * README: Update. * README.non-free: New file - README for non-free distribution. * fortune/README.linux: Update. * bog/README.linux: Update. Thu May 1 00:45:58 1997 Joseph S. Myers * atc/Makefile, battlestar/Makefile, canfield/canfield/Makefile, cribbage/Makefile, robots/Makefile, sail/Makefile, snake/snake/Makefile, tetris/Makefile: Use INSTALL_SCORE_FILE. * tetris/Makefile (install): Use INSTALL_SCORE_GAME. * configure, Makeconfig.in: Update for this. * install-score.in: New file - install a score file. * TODO: Update. * INSTALL: Update. * README.linux: Update. * arithmetic/README.linux, atc/README.linux, battlestar/README.linux, bcd/README.linux, caesar/README.linux, canfield/README.linux, cribbage/README.linux, factor/README.linux, fish/README.linux, hangman/README.linux, mille/README.linux, monop/README.linux, morse/README.linux, number/README.linux, paranoia/README.linux, pom/README.linux, ppt/README.linux, primes/README.linux, rain/README.linux, robots/README.linux, sail/README.linux, snake/README.linux, trek/README.linux, wargames/README.linux, worm/README.linux, worms/README.linux, wump/README.linux: Remove. * fortune/fortune/Makefile: Remove unused definition. * configure, Makeconfig.in, atc/Makefile, backgammon/Makefile, backgammon/backgammon/Makefile, backgammon/common_source/Makefile, backgammon/teachgammon/Makefile, battlestar/Makefile, bog/Makefile, bog/bog.6.in, canfield/Makefile, canfield/canfield/Makefile, canfield/cfscores/Makefile, canfield/canfield/canfield.6.in, cribbage/Makefile, cribbage/cribbage.6.in, fish/Makefile, hangman/Makefile, hangman/hangman.6.in, monop/Makefile, monop/monop.6.in, robots/Makefile, robots/robots.6.in, sail/Makefile, snake/Makefile, snake/snake/Makefile, snake/snake/snake.6.in, snake/snscore/Makefile, tetris/Makefile, tetris/tetris.6.in, wump/Makefile: Configure paths for data files for individual games with configure script. * configure: Find default list of games to build from what directories are present. * Version 1.3.1beta privately distributed for comments. * NEWS: New file - summary of changes. * TODO: Update. * README.linux: Update. * INSTALL: Update. * tetris/Makefile: Install manual page as tetris-bsd.6. * bsd-games.lsm: Update. Wed Apr 30 00:45:55 1997 Joseph S. Myers * INSTALL: Update. * TODO: Update. * bsd-games.lsm: Update. * wump/Makefile (install): Use INSTALL_PREFIX. * canfield/canfield/Makefile (install): Use INSTALL_PREFIX. * Makefile (install): Fix typo. * rain/Makefile: Add target `all'; fix dependencies. * ppt/Makefile: Add target `all'. * pom/Makefile: Add target `all'. * paranoia/Makefile: Add target `all'. * number/Makefile: Add target `all'. * morse/Makefile: Add target `all'. * fish/Makefile: Add target `all'. * factor/Makefile: Add target `all'. * caesar/Makefile: Add target `all'. * bcd/Makefile: Add target `all'. * arithmetic/Makefile: Add target `all'. * snake/snake/snake.h: Use instead of . Tue Apr 29 10:37:00 1997 Joseph S. Myers * Makefile (distclean): Delete all substituted-in manpages. * fortune/fortune/Makefile, fortune/datfiles/Makefile: Fortunes go under $(LIBDIR), not $(SHAREDIR). * TODO: Update. * Credits: Update. * Debian patch (1.3-7), and David Frey's ports, now integrated into the source, at least where I thought the fixes were correct and needed. * gomoku/pickmove.c: Include instead of (from David Frey's port). * gomoku/gomoku.h: Include (from David Frey's port). * gomoku/Makefile: Rename to Makefile.orig * gomoku/Makefile: New from port by David Frey; rewrite to use config information; fix dependencies. * configure: Add gomoku to list of directories to build in. * gomoku/*: Added from NetBSD-current, for adding port from David Frey. * tetris/tetris.6: Rename to tetris.6.in. * tetris/tetris.6.in: Parametrise. * configure: Substitute in this file. * tetris/pathnames.h: Path to score file is defined in the Makefile. * tetris/Makefile: Rename to Makefile.orig. * tetris/Makefile: New from port by David Frey; rewrite to use config information; fix dependencies. * configure: Add tetris to list of directories to build in. * tetris/*: Added from FreeBSD-current (as a basis to include port from David Frey ). Mon Apr 28 12:22:57 1997 Joseph S. Myers * wump/README.linux: Update. * wump/Makefile: Rewrite to use config information; fix dependencies. * worms/worms.c (main): Include (from Debian). * worms/worms.6: Change -length to -l, -number to -n (from Debian). * worms/README.linux: Update. * worms/Makefile: Rewrite to use config information; fix dependencies. * worm/worm.c: Include (from Debian); don't define baudrate(). * worm/README.linux: Update. * worm/Makefile: Rewrite to use config information; fix dependencies. * wargames/README.linux: Update. * wargames/Makefile: Rewrite to use config information. * wargames/wargames.sh: Remove. * wargames/wargames: Change `tput cl' to `tput clear'. * trek/trek.6: Rename to trek.6.in. * trek/trek.6.in: Parametrise. * configure: Substitute in this file. * trek/README.linux: Update. * trek/Makefile: Rewrite to use config information; fix dependencies. * snake/snscore/snscore.c (main): Initialise noplayers; check for empty scorefile (from Debian). * snake/snscore/snscore.c (MAXPLAYERS): Increase to 65534 (from Debian). * snake/snake/snake.6: Rename to snake.6.in. * snake/snake/snake.6.in: Parametrise. * configure: Substitute in this file. * snake/snscore/Makefile: Rewrite to use config information; fix dependencies. * snake/snake/Makefile: Rewrite to use config information; fix dependencies. * snake/README.linux: Update. * snake/Makefile: Rewrite to use config information; use `set -e' in compound commands. Sun Apr 27 00:02:40 1997 Joseph S. Myers * sail/pl_7.c (susp): Don't call tstp (from Debian). * sail/player.h: Mark `version' as `extern'. * sail/externs.h: Mark variables as `extern'. * sail/driver.h: Mark `dtab' as `extern'. * sail/player.h: Change to . * sail/externs.h: Don't include . * sail/Makefile: Rewrite to use config information; fix dependencies. * robots/init_field.c (init_field), robots/move.c (get_move): Don't call flushok. * robots/main.c (quit): Condition out bit using CE (from Debian). * robots/robots.h, robots/move.c: Use character constants as argument to CTRL macro. * robots/robots.6: Rename to robots.6.in. * robots/robots.6.in: Parametrise. * configure: Substitute in this file. * robots/Makefile: Rewrite to use config information; fix dependencies. * rain/Makefile: Rewrite to use config information; fix dependencies. * rain/rain.c: Include (from Debian). * factor/Makefile: Build pr_tbl.o in current directory, not in primes directort. * primes/README.linux: Update. * primes/Makefile: Rewrite to use config information; fix dependencies. * ppt/README.linux: Update. * ppt/Makefile: Rewrite to use config information; fix dependencies. * battlestar/Makefile (install): Add use of $(HIDE_GAME). * pom/pom.c (main): Return 0. * pom/README.linux: Update. * pom/pom.c: Define isleap only if not defined; condition definition of PI on PI rather than linux not being defined; improve value of PI. * pom/Makefile: Rewrite to use config information; fix dependencies. * paranoia/paranoia.c (page40): Remove backslash from invalid "\`" escape sequence. * paranoia/README.linux: Update. * paranoia/Makefile: Rewrite to use config information; fix dependencies. * hide-game.in: Use installation prefix. * number/README.linux: Update. * number/Makefile: Rewrite to use config information; fix dependencies. * morse/README.linux: Update. * morse/Makefile: Rewrite to use config information; fix dependencies. * monop/README.linux: Update. * monop/Makefile: Rewrite to use config information; fix dependencies. * hangman/Makefile, hunt/Makefile, mille/Makefile: Add use of $(HIDE_GAME). * monop/monop.6: Rename to monop.6.in. * monop/monop.6.in: Parametrise. * configure: Substitute in this file. Sat Apr 26 19:10:52 1997 Joseph S. Myers * mille/README.linux: Update. * mille/init.c (newscore): Add force_counter hack from Debian to fix problem with ncurses's addch not returning ERR at EOL. * mille/unctrl.h: Do nothing if NCURSES_VERSION is defined. * mille/Makefile: Rewrite to use config information; fix dependencies. * mille/mille.6: Rename to mille.6.in. * mille/mille.6.in: Parametrise * configure: Substitute in this file. * hunt/README.linux: Update. * hunt/Makefile: Rewrite to use config information. * hunt/otto.c (SCREEN): Define appropriately for ncurses, conditional on NCURSES_VERSION (from Debian). * hunt/pathname.c: Change socket directory to _PATH_SOCKETS (to be defined in the Makefile). * hunt/driver.c (init): Conditionally use /var/tmp instead of /usr/tmp. * hunt/faketalk.c (faketalk): Fix typo (`stmp' for `smtp'). * hunt/hunt.6: Rename to hunt.6.in. * hunt/huntd.6: Rename to huntd.6.in. * hunt/hunt.6.in: Parametrise. * hunt/huntd.6.in: Parametrise. * configure: Substitute in these files. * hangman/README.linux: Update. * hangman/hangman.6: Rename to hangman.6.in. * hangman/hangman.6.in: Parametrise. * configure: Substitute in this file. * hangman/clean.pl, hangman/util, hangman/util.cc: Remove. * hangman/Makefile: Rewrite to use config information; fix dependencies. Thu Apr 24 00:02:10 1997 Joseph S. Myers * fortune/fortune/Makefile: Don't keep rebuilding fortune.test. * fortune/Makefile: Remove fortunes symlink in clean. * fortune/unstr/unstr.c: Don't typedef off_t. * fortune/fortune/fortune.c: Conditionally define d_namlen to d_reclen. * fortune/strfile/strfile.c: Don't typedef off_t, or undefine MAXPATHLEN. * fortune/unstr/Makefile: Rewrite to use config information. * fortune/strfile/Makefile: Rewrite to use config information. * fortune/fortune/Makefile: Rewrite to use config information; fix dependencies. * fortune/datfiles/Makefile: Rewrite to use config information. * fortune/Makefile: Rewrite. * fish/README.linux: Update. * fish/fish.c (nrandom): Condition out declaration of random() (from Debian). * fish/Makefile: Rewrite to use config information; fix dependencies. * factor/README.linux: Update. * factor/Makefile: Rewrite to use config information; fix dependencies. Wed Apr 23 00:03:24 1997 Joseph S. Myers * cribbage/cribbage.6: Rename to cribbage.6.in. * cribbage/cribbage.6.in: Parametrise; add mention of score file and instructions file. * configure: Substitute in this file. * cribbage/README.linux: Update. * cribbage/crib.c, cribbage/extern.c, cribbage/io.c, cribbage/support.c: Change conditional inclusion of ncurses.h or curses.h to unconditional inclusion of curses.h (ncurses provides curses.h in the appropriate directory, used with -I if needed, but ncurses.h is non-standard). * cribbage/instr.c (instructions): Change `pstat' to an int; use WEXITSTATUS macro (from Debian). * cribbage/extern.c: Change `bool' to `BOOLEAN' (from Debian). * cribbage/Makefile: Rewrite to use config information; fix dependencies. * canfield/cfscores/Makefile: Don't use unnecessary libraries. * canfield/Makefile, canfield/canfield/Makefile, canfield/cfscores/Makefile: Fix quoting of SCOREFILE. * canfield/README.linux: Update. * canfield/canfield/canfield.6: Rename to canfield.6.in. * canfield/canfield/canfield.6.in: Parametrise. * configure: Substitute in canfield/canfield/canfield.6.in. * canfield/cfscores/Makefile: Rewrite to use config information. * canfield/canfield/Makefile: Rewrite to use config information. * canfield/Makefile: Rewrite to use config information; use `set -e' in compound commands. Tue Apr 22 00:08:42 1997 Joseph S. Myers * caesar/README.linux: Update. * caesar/Makefile: Rewrite to use config information; fix dependencies. * bog/README.linux: Update. * bog/Makefile: Rewrite to use config information; fix dependencies. * bog/bog.man: Rename to bog.6.in. * bog/bog.6.in: Include parametrised file locations. * configure: Substitute in this file. * arithmetic/Makefile, atc/Makefile, backgammon/backgammon/Makefile, backgammon/teachgammon/Makefile, bcd/Makefile: Use $(HIDE_GAME). * hide-game.in: Use `set -e'. * configure: Ask for permissions on dm (not included yet, but supported for when it is ported). * Makeconfig.in (INSTALL_DM): Provide macro for this. * arithmetic/Makefile, atc/Makefile, backgammon/backgammon/Makefile, backgammon/common_source/Makefile, backgammon/teachgammon/Makefile, battlestar/Makefile, bcd/Makefile: Use LDFLAGS in link. * bcd/README.linux: Update. * bcd/Makefile: Rewrite to use config information; fix dependencies. * install-man.in: Set owner/group/permissions on .so pages. * battlestar/fly.c (visual): Check return of initscr() against NULL rather than ERR to eliminate warning (although initscr() should exit in event of error). Also comment out call to savetty(). * battlestar/fly.c (endfly): Add call to setvbuf() to restore line buffering on stdout, since ncurses changes buffering but doesn't restore it. * battlestar/save.c: Do exit(1) on failed restore; close file at the end of restore() and save(). * battlestar/externs.h: Conditionally include and . * battlestar/dayfile.c (dayfile): Spelling corrections. * battlestar/nightfile.c (nightfile): Spelling corrections. * battlestar/cypher.c (cypher): Fix many tests on *objsht[n] that should be on objsht[n]; initialise `wordtype' correctly in TAKE when doing a `take all'. * battlestar/com5.c (give): Initialise `last1' and `last2' to avoid a segfault if you start the game with `give'. * battlestar/com3.c (shoot): Initialise `firstnumber' to avoid segfault from `shoot all' without a laser. * battlestar/com2.c (use): Set notes[CANTSEE] to 0 when moving into the light. * battlestar/battlestar.c: Change exit() to exit(1) in default case that shouldn't occur. * battlestar/externs.h: Mark as `extern' variables initialised somewhere. * battlestar/fly.c: Change to . * battlestar/README.linux: Update. * battlestar/Makefile: Rewrite to use config information; fix dependencies. Mon Apr 21 22:19:28 1997 Joseph S. Myers * configure: New variable `chown_vardata' to set owner/group on variable data only if appropriate. * Makeconfig.in: Use this variable. Sat Apr 19 20:06:08 1997 Joseph S. Myers * backgammon/Makefile: Add missing semi-colon, and `cd ..'s. * backgammon/common_source/subs.c (getarg): Check s[0] for being NULL (from Debian). * backgammon/backgammon/main.c, backgammon/backgammon/move.c, backgammon/backgammon/text.c, backgammon/commmon_source/back.h, backgammon/common_source/board.c, backgammon/teachgammon/teach.c, backgammon/teachgammon/ttext1.c, backgammon/teachgammon/ttext2.c: Change `raw' to `bg_raw', and `remove' to `removetxt' (from Debian). * backgammon/teachgammon/teach.c: Mark variables as `extern'. * backgammon/teachgammon/teach.c: Change `ospeed' to `short'. * backgammon/backgammon/main.c: Mark `instr' and `message' as `extern'. Also change `ospeed' from `char' to `short' (from Debian). * backgammon/common_source/back.h: Mark as `extern' variables initialised in init.c. * backgammon/common_source/back.h, backgammon/common_source/init.c: Don't condition on linux for including or , since redundant with -I/usr/include/bsd. * backgammon/README.linux: Update. * atc/Makefile, backgammon/backgammon/Makefile, backgammon/teachgammon/Makefile: Consistently use $(INCS) in compilation rules. * backgammon/common_source/Makefile: Rewrite to use config information; fix dependencies. * backgammon/backgammon/backgammon.6.in: Include teachgammon in manpage (from Debian). * backgammon/teachgammon/Makefile: Install .so link or symlink to backgammon manpage. Fri Apr 18 11:02:30 1997 Joseph S. Myers * install-man.in: New file to handle all the manpage installation complexities. * configure, Makeconfig.in, arithmetic/Makefile, atc/Makefile, backgammon/backgammon/Makefile: Use this new script. * backgammon/backgammon/Makefile, backgammon/teachgammon/Makefile: Rewrite to use config information; fix dependencies. * backgammon/backgammon/backgammon.6: Rename to backgammon.6.in. * backgammon/backgammon/backgammon.6.in: Parametrise reference to teachgammon. * configure: Substitute in backgammon/backgammon/backgammon.6.in. * backgammon/Makefile: Rewrite to use config information. * atc/README.linux: Update. * atc/main.c (main): Add CRMOD to terminal flags, since ncurses 1.9.9g (3.4) and 4.0 disable CR-NL translation. Thu Apr 17 12:31:00 1997 Joseph S. Myers * atc/Makefile: Rewrite to use config information; fix dependencies; fix libraries and installation of games (from Debian). * atc/include.h: Remove conditional inclusion of , as it's redundant with -I/usr/include/bsd. * atc/def.h: Change #ifndef linux to #ifndef PI for definition of PI (from Debian). Also improve accuracy of value. * arithmetic/arithmetic.c: include ; remove declaration of time(). * Makeconfig.in (CC): Add new macro. * arithmetic/Makefile: Rewrite to use config information; fix dependencies. * arithmetic/README.linux: Update. * Makeconfig.in (BUILDDIRS): Add new macro. * configure: Always substitute for sbindir, socketdir and usrbindir, even if not building relevant programs (so that we can always create them). * Makefile: Essentially complete rewrite to use configuration information; allow installation prefix and use install -d instead of mkdir -p as per Debian patch. Also use set -e in all compound commands. * Makeconfig.in (INSTALL_SCORE_FILE2, INSTALL_SCORE_FILE3): Fix commands for installing score files. * configure, Makeconfig.in: Add configuration of socketdir, for hunt to place its Unix domain sockets in. Wed Apr 16 21:31:18 1997 Joseph S. Myers * BSD-games.src.lsm: Remove. * bsd-games.lsm: New file - new-style LSM entry. * configure, Makeconfig.in, hide-game.in: New files - beginnings of a configuration system. * CHANGELOG: Rename to ChangeLog.0. * ChangeLog: New file. * BSD-games.bin.lsm: Remove. * New maintainer. See ChangeLog.0 for earlier changes. bsd-games-2.17/install-score.in0000775000175000017500000000351207250165574015125 0ustar jsm28jsm28# install-score.in - install a score file # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. set -e if [ "$1" = "-p" ]; then scorefile="@install_prefix@$2" perms=@vardata_perms_priv@ else scorefile="@install_prefix@$1" perms=@vardata_perms@ fi mkdir -p "$(dirname "$scorefile")" test -e "$scorefile" || touch "$scorefile" if [ @do_chown@ = y ]; then chown @vardata_owner@:@vardata_group@ "$scorefile" fi chmod "$perms" "$scorefile" bsd-games-2.17/PACKAGING0000664000175000017500000001603210011562133013200 0ustar jsm28jsm28Packaging bsd-games and bsd-games-non-free ========================================== This file contains some information intended for those packaging bsd-games or bsd-games-non-free for a Linux distribution. It is presumed that you have read INSTALL first, and that you have the competence in the POSIX shell required to read and understand the configure script. This information may also be useful to people building their own systems, who wish to rebuild the whole system automatically or who use a packaging system for locally built software. The configuration and build of bsd-games has two features designed to facilitate packaging: 1) Installation prefix. The configure script allows you to choose an installation prefix (by default empty) that is prepended to all paths used for installation, but not those built into the executables (this is similar to the install_root of glibc, and DESTDIR in some packages, but is chosen at configure time). The package would then be built in some way from this directory, and the contents would end up in the root of the target system. If used, this prefix must be an absolute path. 2) config.params to change configuration defaults. Although the configuration script is by default interactive (although it does not need a terminal), it can also be used non-interactively. If a file "config.params" exists in the source directory, it will be sourced by the configure script. If this file (which can be an arbitrary shell script) sets "bsd_games_cfg_non_interactive" to "y", then the default answers to all questions will be taken without interaction. If this sets "bsd_games_cfg_FOO" to "BAR" then the default value for configuration parameter "FOO" will become "BAR" instead of whatever default the script would otherwise give. You can find the names and meanings of the configuration parameters by reading the configure script; they are not otherwise documented. Issues for packagers ==================== Please read the security warnings in SECURITY. There is a potential trade-off between security and functionality present, and you may wish to choose a potentially more secure default and allow the sysadmin to change permissions if they are in an environment (for example, a home system with only trusted users) where the functionality is preferred, while ensuring such changes persist across upgrades. Some packagers may wish to provide a security-hardened system by giving each setgid game its own group so bugs in one do not affect others. You may wish to include auxiliary documentation for users, such as the AUTHORS and THANKS files and the year 2000 statement YEAR2000. Assuming you distribute source for your package (I do not believe any of the games have licences requiring this), and separate your patches from the original source .tar.gz files (whether in separate files or in a single file source package including them as separable components), arranging the building of the source so that your patches add a "config.params" as described above, and do any other necessary changes to "configure" or other source files, and so that the build process runs configure non-interactively and then builds the package, makes it easier for readers to see how you have packaged it than running configure interactively and including the generated files in your patch. Since bsd-games no longer comes with its own words file, you may wish to ensure that the same dictionaries are used in the build of boggle regardless of the local configuration of the dictionaries installed on the computer used for the build. (The list used by hangman can also be specified by the user at run time; future versions may provide for this to be done with boggle as well; see TODO.) Andries Brouwer has noted more than once on linux-kernel (and elsewhere) that some packagers (for various software and documentation used under Linux): (a) Do not send their patches to upstream maintainers, so that improvements and bug fixes stay in some distributions, which may need to discover them independently, and do not come to benefit other users. (b) Keep applying their same patches to new versions of the source as long as they apply without error, even though they may no longer be needed or even be harmful. If you have patches that are needed for the package to build or to fix bugs (in a supported environment, not with old versions of libraries and tools) or that provide enhancements other than conforming to distribution-specific policy, please send them to me (unidiffs preferred; see notes on bug reporting and sending patches at the end of README). Do not assume that old patches should be applied to new versions; check that the problem they are supposed to fix is still present first. Warnings ======== If distributing bsd-games, it is your responsibility to check that the licences on the games you distribute permit what you wish to do with them, and that you are providing accurate information on the licences to your users. Likewise it is your responsibility to carry out whatever audits you deem necessary on the code, and to include such warnings or information (about security and otherwise) for the end user as you see fit. Please read the disclaimers in the individual source files. Some of the games may contain material, actions or language that in some jurisdictions may be prohibited or considered unsuitable for minors; this includes but is not limited to the offensive fortunes. It is your responsibility to determine and apply any restriction on your distribution of the games that may be necessary in consequence. This package contains cryptographic software (caesar and rot13). See the warnings in README about this. Notification of new versions ============================ If you want to receive notification of new versions by email, but do not currently receive this notification, please let me know. A note on terminology and credit ================================ I am not the "upstream author" of the games packaged here; for an incomplete list of the authors see AUTHORS, but do not give me this credit I do not deserve at the expense of the true authors. Rather I am the "upstream maintainer" of the bsd-games and bsd-games-non-free packages (upstream relative to distributions), and upstream of me is NetBSD, who also are maintainers of the games, but not for the most part authors. Nor am I the creator of the bsd-games package, although much the current form of the packaging and many of the porting changes are mine: the package was created by Curt Olson and Andy Tefft, and passed to me after it had been idle and unmaintained for some years. Any system that provides fields for recording this sort of information should distinguish these concepts, and the different fields should be filled in correctly. Please consider where credit is due and credit the authors of the games accordingly: if you find the names of authors where not known and listed in AUTHORS, or up-to-date contact details for authors listed there, please send me the details so they can receive their due credit in future versions, and thanks from any appreciative users. Local Variables: mode: text End: bsd-games-2.17/Makefile.bsd0000664000175000017500000000100307775331303014210 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.21 2003/12/26 17:59:13 christos Exp $ # @(#)Makefile 8.3 (Berkeley) 7/24/94 # Missing: ching dungeon warp # Moved: chess # Don't belong: xneko xroach SUBDIR= adventure arithmetic atc backgammon banner battlestar bcd boggle \ caesar canfield countmail cribbage dab dm factor fish fortune gomoku \ hack hangman hunt larn mille monop morse number phantasia pig pom ppt \ primes quiz rain random robots rogue sail snake tetris trek wargames \ worm worms wtf wump .include bsd-games-2.17/monop/0000775000175000017500000000000010205246607013131 5ustar jsm28jsm28bsd-games-2.17/monop/pathnames.h.in0000664000175000017500000000332107767741711015705 0ustar jsm28jsm28/* $NetBSD: pathnames.h,v 1.4 2003/08/07 09:37:29 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 5/31/93 */ #define _PATH_CARDS "@monop_cardsfile@" bsd-games-2.17/monop/cards.inp0000664000175000017500000000366207114231202014732 0ustar jsm28jsm28FF >> GET OUT OF JAIL FREE << Keep this card until needed or sold %% ++25 Receive for Services $25. %% ++200 Bank Error in Your Favor. Collect $200. %% ++20 Income Tax Refund. Collect $20. %% --100 Pay Hospital $100 %% ++100 Life Insurance Matures. Collect $100 %% ++45 From sale of Stock You get $45. %% TX You are Assessed for street repairs. $40 per House $115 per Hotel %% ++100 X-mas Fund Matures. Collect $100. %% ++11 You have won Second Prize in a Beauty Contest Collect $11 %% MF0 Advance to GO (Collect $200) %% ++100 You inherit $100 %% --150 Pay School Tax of $150. %% MJ >> GO TO JAIL << Go Directly to Jail. Do not pass GO Do not collect $200. %% +A50 >> GRAND OPERA OPENING << Collect $50 from each player for opening night seats. %% --50 Doctor's Fee: Pay $50. %- FF >> GET OUT OF JAIL FREE << Keep this card until needed or sold %% MR Advance to the nearest Railroad, and pay owner Twice the rental to which he is otherwise entitled. If Railroad is unowned you may buy it from the bank %% MU Advance to the nearest Utility. If unowned, you may buy it from the bank. If owned, throw dice and pay oner a total of ten times the amount thrown. %% MB3 Go Back 3 Spaces %% MR Advance to the nearest Railroad, and pay owner Twice the rental to which he is otherwise entitled. If Railroad is unowned you may buy it from the bank %% MJ >> GO DIRECTLY TO JAIL << Do not pass GO, Do not Collect $200. %% MF5 Take a Ride on the Reading. If you pass GO, collect $200. %% MF39 Take a Walk on the Board Walk. (Advance To Board Walk) %% MF24 Advance to Illinois Ave. %% MF0 Advance to Go %% MF11 Advance to St. Charles Place. If you pass GO, collect $200. %% TX Make general repairs on all of your Property. For Each House pay $25. For Each Hotel pay $100. %% -A50 You have been elected Chairman of the Board. Pay each player $50. %% --15 Pay Poor Tax of $15 %% ++50 Bank pays you Dividend of $50. %% ++150 Your Building and Loan Matures. Collect $150. bsd-games-2.17/monop/trade.c0000664000175000017500000001760010005547567014407 0ustar jsm28jsm28/* $NetBSD: trade.c,v 1.9 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)trade.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: trade.c,v 1.9 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include "monop.ext" struct trd_st { /* how much to give to other player */ int trader; /* trader number */ int cash; /* amount of cash */ int gojf; /* # get-out-of-jail-free cards */ OWN *prop_list; /* property list */ }; typedef struct trd_st TRADE; static const char *plist[MAX_PRP+2]; static int used[MAX_PRP]; static TRADE trades[2]; static void get_list(int, int ); static int set_list(OWN *); static void summate(void); static void do_trade(void); static void move_em(TRADE *, TRADE *); void trade() { int tradee, i; trading = TRUE; for (i = 0; i < 2; i++) { trades[i].cash = 0; trades[i].gojf = FALSE; trades[i].prop_list = NULL; } over: if (num_play == 1) { printf("There ain't no-one around to trade WITH!!\n"); return; } if (num_play > 2) { tradee = getinp("Which player do you wish to trade with? ", name_list); if (tradee == num_play) return; if (tradee == player) { printf("You can't trade with yourself!\n"); goto over; } } else tradee = 1 - player; get_list(0, player); get_list(1, tradee); if (getyn("Do you wish a summary? ") == 0) summate(); if (getyn("Is the trade ok? ") == 0) do_trade(); } /* * This routine gets the list of things to be trader for the * player, and puts in the structure given. */ static void get_list(struct_no, play_no) int struct_no, play_no; { int sn, pn; PLAY *pp; int numin, prop, num_prp; OWN *op; TRADE *tp; for (numin = 0; numin < MAX_PRP; numin++) used[numin] = FALSE; sn = struct_no, pn = play_no; pp = &play[pn]; tp = &trades[sn]; tp->trader = pn; printf("player %s (%d):\n", pp->name, pn+1); if (pp->own_list) { numin = set_list(pp->own_list); for (num_prp = numin; num_prp; ) { prop = getinp("Which property do you wish to trade? ", plist); if (prop == numin) break; else if (used[prop]) printf("You've already allocated that.\n"); else { num_prp--; used[prop] = TRUE; for (op = pp->own_list; prop--; op = op->next) continue; add_list(pn, &(tp->prop_list), sqnum(op->sqr)); } } } if (pp->money > 0) { printf("You have $%d. ", pp->money); tp->cash = get_int("How much are you trading? "); } if (pp->num_gojf > 0) { once_more: printf("You have %d get-out-of-jail-free cards. ",pp->num_gojf); tp->gojf = get_int("How many are you trading? "); if (tp->gojf > pp->num_gojf) { printf("You don't have that many. Try again.\n"); goto once_more; } } } /* * This routine sets up the list of tradable property. */ static int set_list(the_list) OWN *the_list; { int i; OWN *op; i = 0; for (op = the_list; op; op = op->next) if (!used[i]) plist[i++] = op->sqr->name; plist[i++] = "done"; plist[i--] = 0; return i; } /* * This routine summates the trade. */ static void summate() { bool some; int i; TRADE *tp; OWN *op; for (i = 0; i < 2; i++) { tp = &trades[i]; some = FALSE; printf("Player %s (%d) gives:\n", play[tp->trader].name, tp->trader+1); if (tp->cash > 0) printf("\t$%d\n", tp->cash), some++; if (tp->gojf > 0) printf("\t%d get-out-of-jail-free card(s)\n", tp->gojf), some++; if (tp->prop_list) { for (op = tp->prop_list; op; op = op->next) putchar('\t'), printsq(sqnum(op->sqr), TRUE); some++; } if (!some) printf("\t-- Nothing --\n"); } } /* * This routine actually executes the trade. */ static void do_trade() { move_em(&trades[0], &trades[1]); move_em(&trades[1], &trades[0]); } /* * This routine does a switch from one player to another */ static void move_em(from, to) TRADE *from, *to; { PLAY *pl_fr, *pl_to; OWN *op; pl_fr = &play[from->trader]; pl_to = &play[to->trader]; pl_fr->money -= from->cash; pl_to->money += from->cash; pl_fr->num_gojf -= from->gojf; pl_to->num_gojf += from->gojf; for (op = from->prop_list; op; op = op->next) { add_list(to->trader, &(pl_to->own_list), sqnum(op->sqr)); op->sqr->owner = to->trader; del_list(from->trader, &(pl_fr->own_list), sqnum(op->sqr)); } set_ownlist(to->trader); } /* * This routine lets a player resign */ void resign() { int i, new_own; OWN *op; SQUARE *sqp; if (cur_p->money <= 0) { switch (board[cur_p->loc].type) { case UTIL: case RR: case PRPTY: new_own = board[cur_p->loc].owner; break; default: /* Chance, taxes, etc */ new_own = num_play; break; } if (new_own == num_play) printf("You would resign to the bank\n"); else printf("You would resign to %s\n", name_list[new_own]); } else if (num_play == 1) { new_own = num_play; printf("You would resign to the bank\n"); } else { name_list[num_play] = "bank"; do { new_own = getinp("Who do you wish to resign to? ", name_list); if (new_own == player) printf("You can't resign to yourself!!\n"); } while (new_own == player); name_list[num_play] = "done"; } if (getyn("Do you really want to resign? ") != 0) return; if (num_play == 1) { printf("Then NOBODY wins (not even YOU!)\n"); exit(0); } if (new_own < num_play) { /* resign to player */ printf("resigning to player\n"); trades[0].trader = new_own; trades[0].cash = trades[0].gojf = 0; trades[0].prop_list = NULL; trades[1].trader = player; trades[1].cash = cur_p->money > 0 ? cur_p->money : 0; trades[1].gojf = cur_p->num_gojf; trades[1].prop_list = cur_p->own_list; do_trade(); } else { /* resign to bank */ printf("resigning to bank\n"); for (op = cur_p->own_list; op; op = op->next) { sqp = op->sqr; sqp->owner = -1; sqp->desc->morg = FALSE; if (sqp->type == PRPTY) { is_not_monop(sqp->desc->mon_desc); sqp->desc->houses = 0; } } if (cur_p->num_gojf) ret_card(cur_p); } for (i = player; i < num_play; i++) { name_list[i] = name_list[i+1]; if (i + 1 < num_play) play[i] = play[i+1]; } name_list[num_play--] = 0; for (i = 0; i < N_SQRS; i++) if (board[i].owner > player) --board[i].owner; player = --player < 0 ? num_play - 1 : player; next_play(); if (num_play < 2) { printf("\nThen %s WINS!!!!!\n", play[0].name); printhold(0); printf("That's a grand worth of $%d.\n", play[0].money+prop_worth(&play[0])); exit(0); } } bsd-games-2.17/monop/Makefile.bsd0000664000175000017500000000113707767741711015361 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.27 2003/11/16 14:14:18 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 .include PROG= monop SRCS= monop.c cards.c execute.c getinp.c houses.c jail.c malloc.c misc.c \ morg.c print.c prop.c rent.c roll.c spec.c trade.c MAN= monop.6 HIDEGAME=hidegame CLEANFILES+=initdeck initdeck.lo cards.pck .if ${MKSHARE} != "no" FILES=cards.pck FILESDIR=/usr/share/games .endif realall: ${FILES} initdeck: initdeck.lo ${_MKTARGET_LINK} ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} cards.pck: initdeck ${_MKTARGET_CREATE} ./initdeck ${.CURDIR}/cards.inp .include bsd-games-2.17/monop/execute.c0000664000175000017500000001357610005547567014762 0ustar jsm28jsm28/* $NetBSD: execute.c,v 1.11 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: execute.c,v 1.11 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include "monop.ext" #include #include #include #include #include #include #include #define SEGSIZE 8192 typedef struct stat STAT; typedef struct tm TIME; static char buf[257]; static bool new_play; /* set if move on to new player */ extern void *heapstart; static void show_move(void); /* * This routine executes the given command by index number */ void execute(com_num) int com_num; { new_play = FALSE; /* new_play is true if fixing */ (*func[com_num])(); notify(); force_morg(); if (new_play) next_play(); else if (num_doub) printf("%s rolled doubles. Goes again\n", cur_p->name); } /* * This routine moves a piece around. */ void do_move() { int r1, r2; bool was_jail; new_play = was_jail = FALSE; printf("roll is %d, %d\n", r1=roll(1, 6), r2=roll(1, 6)); if (cur_p->loc == JAIL) { was_jail++; if (!move_jail(r1, r2)) { new_play++; goto ret; } } else { if (r1 == r2 && ++num_doub == 3) { printf("That's 3 doubles. You go to jail\n"); goto_jail(); new_play++; goto ret; } move(r1+r2); } if (r1 != r2 || was_jail) new_play++; ret: return; } /* * This routine moves a normal move */ void move(rl) int rl; { int old_loc; old_loc = cur_p->loc; cur_p->loc = (cur_p->loc + rl) % N_SQRS; if (cur_p->loc < old_loc && rl > 0) { cur_p->money += 200; printf("You pass %s and get $200\n", board[0].name); } show_move(); } /* * This routine shows the results of a move */ static void show_move() { SQUARE *sqp; sqp = &board[cur_p->loc]; printf("That puts you on %s\n", sqp->name); switch (sqp->type) { case SAFE: printf("That is a safe place\n"); break; case CC: cc(); break; case CHANCE: chance(); break; case INC_TAX: inc_tax(); break; case GOTO_J: goto_jail(); break; case LUX_TAX: lux_tax(); break; case PRPTY: case RR: case UTIL: if (sqp->owner < 0) { printf("That would cost $%d\n", sqp->cost); if (getyn("Do you want to buy? ") == 0) { buy(player, sqp); cur_p->money -= sqp->cost; } else if (num_play > 2) bid(); } else if (sqp->owner == player) printf("You own it.\n"); else rent(sqp); } } /* * This routine saves the current game for use at a later date */ void save() { char *sp; int outf, num; time_t t; struct stat sb; char *start, *end; printf("Which file do you wish to save it in? "); sp = buf; while ((*sp++=getchar()) != '\n') continue; *--sp = '\0'; /* * check for existing files, and confirm overwrite if needed */ if (stat(buf, &sb) > -1 && getyn("File exists. Do you wish to overwrite? ") > 0) return; if ((outf=creat(buf, 0644)) < 0) { perror(buf); return; } printf("\"%s\" ", buf); time(&t); /* get current time */ strcpy(buf, ctime(&t)); for (sp = buf; *sp != '\n'; sp++) continue; *sp = '\0'; start = heapstart; end = sbrk(0); while (start < end) { /* write out entire data space */ num = start + 16 * 1024 > end ? end - start : 16 * 1024; write(outf, start, num); start += num; } close(outf); printf("[%s]\n", buf); } /* * This routine restores an old game from a file */ void restore() { char *sp; printf("Which file do you wish to restore from? "); for (sp = buf; (*sp=getchar()) != '\n'; sp++) continue; *sp = '\0'; rest_f(buf); } /* * This does the actual restoring. It returns TRUE if the * backup was successful, else false. */ int rest_f(file) const char *file; { char *sp; int inf, num; char buf[80]; char *start, *end; STAT sbuf; if ((inf=open(file, O_RDONLY)) < 0) { perror(file); return FALSE; } printf("\"%s\" ", file); if (fstat(inf, &sbuf) < 0) { /* get file stats */ perror(file); exit(1); } start = heapstart; brk(end = start + sbuf.st_size); while (start < end) { /* write out entire data space */ num = start + 16 * 1024 > end ? end - start : 16 * 1024; read(inf, start, num); start += num; } close(inf); strcpy(buf, ctime(&sbuf.st_mtime)); for (sp = buf; *sp != '\n'; sp++) continue; *sp = '\0'; printf("[%s]\n", buf); return TRUE; } bsd-games-2.17/monop/monop.def0000664000175000017500000001061410005547567014752 0ustar jsm28jsm28/* $NetBSD: monop.def,v 1.9 2004/01/27 20:30:30 jsm Exp $ */ /*- * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)monop.def 5.5 (Berkeley) 5/31/93 */ #include "deck.h" #include "monop.h" bool fixing, /* set if fixing up debt */ trading, /* set if in process of trading */ told_em, /* set if told user he's out of debt */ spec; /* set if moving by card to RR or UTIL */ const char *name_list[MAX_PL+2], /* list of players' names */ *const comlist[] = { /* list of normal commands */ "quit", /* 0 */ "print", /* 1 */ "where", /* 2 */ "own holdings", /* 3 */ "holdings", /* 4 */ "mortgage", /* 5 */ "unmortgage", /* 6 */ "buy houses", /* 7 */ "sell houses", /* 8 */ "card", /* 9 */ "pay", /* 10 */ "trade", /* 11 */ "resign", /* 12 */ "save", /* 13 */ "restore", /* 14 */ "roll", /* 15 */ "", /* 16 */ 0 }, *const yncoms[] = { /* list of commands for yes/no answers */ "yes", /* 0 */ "no", /* 1 */ "quit", /* 2 */ "print", /* 3 */ "where", /* 4 */ "own holdings", /* 5 */ "holdings", /* 6 */ 0 }, *const lucky_mes[] = { /* "got lucky" messages */ "You lucky stiff", "You got lucky", "What a lucky person!", "You must have a 4-leaf clover", "My, my! Aren't we lucky!", "Luck smiles upon you", "You got lucky this time", "Lucky person!", "Your karma must certainly be together", "How beautifully Cosmic", "Wow, you must be really with it" /* "I want your autograph", -- Save for later */ }; int player, /* current player number */ num_play, /* current number of players */ num_doub, /* # of doubles current player rolled */ /* # of "got lucky" messages */ num_luck = sizeof lucky_mes / sizeof (char *); /* list of command functions */ void (*const func[])(void) = { /* array of function calls for commands */ quit, /* quit game |* 0 *| */ printboard, /* print board |* 1 *| */ where, /* where players are |* 2 *| */ list, /* own holdings |* 3 *| */ list_all, /* holdings list |* 4 *| */ mortgage, /* mortgage property |* 5 *| */ unmortgage, /* unmortgage property |* 6 *| */ buy_houses, /* buy houses |* 7 *| */ sell_houses, /* sell houses |* 8 *| */ card, /* card for jail |* 9 *| */ pay, /* pay for jail |* 10 *| */ trade, /* trade |* 11 *| */ resign, /* resign |* 12 *| */ save, /* save game |* 13 *| */ restore, /* restore game |* 14 *| */ do_move, /* roll |* 15 *| */ do_move /* "" |* 16 *| */ }; DECK deck[2]; /* Chance and Community Chest */ PLAY *play, /* player structure array ("calloc"ed) */ *cur_p; /* pointer to current player's struct */ RR_S rr[N_RR]; /* raildroad descriptions */ UTIL_S util[2]; /* utility descriptions */ MON mon[N_MON] = { /* monopoly descriptions */ # include "mon.dat" }; PROP prop[N_PROP] = { /* typical properties */ # include "prop.dat" }; SQUARE board[N_SQRS+1] = { /* board itself (+1 for Jail) */ # include "brd.dat" }; bsd-games-2.17/monop/morg.c0000664000175000017500000001267210005547567014260 0ustar jsm28jsm28/* $NetBSD: morg.c,v 1.10 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)morg.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: morg.c,v 1.10 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include "monop.ext" /* * These routines deal with mortgaging. */ static const char *names[MAX_PRP+2], *const morg_coms[] = { "quit", /* 0 */ "print", /* 1 */ "where", /* 2 */ "own holdings", /* 3 */ "holdings", /* 4 */ "mortgage", /* 5 */ "unmortgage", /* 6 */ "buy", /* 7 */ "sell", /* 8 */ "card", /* 9 */ "pay", /* 10 */ "trade", /* 11 */ "resign", /* 12 */ "save game", /* 13 */ "restore game", /* 14 */ 0 }; static short square[MAX_PRP+2]; static int num_good,got_houses; static int set_mlist(void); static void m(int); static int set_umlist(void); static void unm(int); static void fix_ex(int); /* * This routine is the command level response the mortgage command. * it gets the list of mortgageable property and asks which are to * be mortgaged. */ void mortgage() { int prop; for (;;) { if (set_mlist() == 0) { if (got_houses) printf("You can't mortgage property with " "houses on it.\n"); else printf("You don't have any un-mortgaged " "property.\n"); return; } if (num_good == 1) { printf("Your only mortageable property is %s\n", names[0]); if (getyn("Do you want to mortgage it? ") == 0) m(square[0]); return; } prop = getinp("Which property do you want to mortgage? ",names); if (prop == num_good) return; m(square[prop]); notify(); } } /* * This routine sets up the list of mortgageable property */ static int set_mlist() { OWN *op; num_good = 0; for (op = cur_p->own_list; op; op = op->next) if (!op->sqr->desc->morg) { if (op->sqr->type == PRPTY && op->sqr->desc->houses) got_houses++; else { names[num_good] = op->sqr->name; square[num_good++] = sqnum(op->sqr); } } names[num_good++] = "done"; names[num_good--] = 0; return num_good; } /* * This routine actually mortgages the property. */ static void m(prop) int prop; { int price; price = board[prop].cost/2; board[prop].desc->morg = TRUE; printf("That got you $%d\n",price); cur_p->money += price; } /* * This routine is the command level repsponse to the unmortgage * command. It gets the list of mortgaged property and asks which are * to be unmortgaged. */ void unmortgage() { int prop; for (;;) { if (set_umlist() == 0) { printf("You don't have any mortgaged property.\n"); return; } if (num_good == 1) { printf("Your only mortaged property is %s\n",names[0]); if (getyn("Do you want to unmortgage it? ") == 0) unm(square[0]); return; } prop = getinp("Which property do you want to unmortgage? ", names); if (prop == num_good) return; unm(square[prop]); } } /* * This routine sets up the list of mortgaged property */ static int set_umlist() { OWN *op; num_good = 0; for (op = cur_p->own_list; op; op = op->next) if (op->sqr->desc->morg) { names[num_good] = op->sqr->name; square[num_good++] = sqnum(op->sqr); } names[num_good++] = "done"; names[num_good--] = 0; return num_good; } /* * This routine actually unmortgages the property */ static void unm(prop) int prop; { int price; price = board[prop].cost/2; board[prop].desc->morg = FALSE; price += price/10; printf("That cost you $%d\n",price); cur_p->money -= price; set_umlist(); } /* * This routine forces the indebted player to fix his * financial woes. */ void force_morg() { told_em = fixing = TRUE; while (cur_p->money <= 0) fix_ex(getinp("How are you going to fix it up? ",morg_coms)); fixing = FALSE; } /* * This routine is a special execute for the force_morg routine */ static void fix_ex(com_num) int com_num; { told_em = FALSE; (*func[com_num])(); notify(); } bsd-games-2.17/monop/houses.c0000664000175000017500000001555110005547567014621 0ustar jsm28jsm28/* $NetBSD: houses.c,v 1.8 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)houses.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: houses.c,v 1.8 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include "monop.ext" static const char *names[N_MON+2]; static char cur_prop[80]; static MON *monops[N_MON]; static void buy_h(MON *); static void sell_h(MON *); static void list_cur(MON *); /* * These routines deal with buying and selling houses */ void buy_houses() { int num_mon; MON *mp; OWN *op; bool good,got_morg; int i,p; over: num_mon = 0; good = TRUE; got_morg = FALSE; for (op = cur_p->own_list; op && op->sqr->type != PRPTY; op = op->next) continue; while (op) if (op->sqr->desc->monop) { mp = op->sqr->desc->mon_desc; names[num_mon] = (monops[num_mon]=mp)->name; num_mon++; got_morg = good = FALSE; for (i = 0; i < mp->num_in; i++) { if (op->sqr->desc->morg) got_morg++; if (op->sqr->desc->houses != 5) good++; op = op->next; } if (!good || got_morg) --num_mon; } else op = op->next; if (num_mon == 0) { if (got_morg) printf("You can't build on mortgaged monopolies.\n"); else if (!good) printf("You can't build any more.\n"); else printf("But you don't have any monopolies!!\n"); return; } if (num_mon == 1) buy_h(monops[0]); else { names[num_mon++] = "done"; names[num_mon--] = 0; if ((p = getinp( "Which property do you wish to buy houses for? ", names)) == num_mon) return; buy_h(monops[p]); goto over; } } static void buy_h(mnp) MON *mnp; { int i; MON *mp; int price; short input[3],temp[3]; int tot; PROP *pp; mp = mnp; price = mp->h_cost * 50; blew_it: list_cur(mp); printf("Houses will cost $%d\n", price); printf("How many houses do you wish to buy for\n"); for (i = 0; i < mp->num_in; i++) { pp = mp->sq[i]->desc; over: if (pp->houses == 5) { printf("%s (H):\n", mp->sq[i]->name); input[i] = 0; temp[i] = 5; continue; } (void)sprintf(cur_prop, "%s (%d): ", mp->sq[i]->name, pp->houses); input[i] = get_int(cur_prop); temp[i] = input[i] + pp->houses; if (temp[i] > 5) { printf("That's too many. The most you can buy is %d\n", 5 - pp->houses); goto over; } } if (mp->num_in == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) { err: printf("That makes the spread too wide. Try again\n"); goto blew_it; } else if (mp->num_in == 2 && abs(temp[0] - temp[1]) > 1) goto err; for (tot = i = 0; i < mp->num_in; i++) tot += input[i]; if (tot) { printf("You asked for %d houses for $%d\n", tot, tot * price); if (getyn("Is that ok? ") == 0) { cur_p->money -= tot * price; for (tot = i = 0; i < mp->num_in; i++) mp->sq[i]->desc->houses = temp[i]; } } } /* * This routine sells houses. */ void sell_houses() { int num_mon; MON *mp; OWN *op; bool good; int p; over: num_mon = 0; good = TRUE; for (op = cur_p->own_list; op; op = op->next) if (op->sqr->type == PRPTY && op->sqr->desc->monop) { mp = op->sqr->desc->mon_desc; names[num_mon] = (monops[num_mon]=mp)->name; num_mon++; good = 0; do if (!good && op->sqr->desc->houses != 0) good++; while (op->next && op->sqr->desc->mon_desc == mp && (op=op->next)); if (!good) --num_mon; } if (num_mon == 0) { printf("You don't have any houses to sell!!\n"); return; } if (num_mon == 1) sell_h(monops[0]); else { names[num_mon++] = "done"; names[num_mon--] = 0; if ((p = getinp( "Which property do you wish to sell houses from? ", names)) == num_mon) return; sell_h(monops[p]); notify(); goto over; } } static void sell_h(mnp) MON *mnp; { int i; MON *mp; int price; short input[3],temp[3]; int tot; PROP *pp; mp = mnp; price = mp->h_cost * 25; blew_it: printf("Houses will get you $%d apiece\n", price); list_cur(mp); printf("How many houses do you wish to sell from\n"); for (i = 0; i < mp->num_in; i++) { pp = mp->sq[i]->desc; over: if (pp->houses == 0) { printf("%s (0):\n", mp->sq[i]->name); input[i] = temp[i] = 0; continue; } if (pp->houses < 5) (void)sprintf(cur_prop,"%s (%d): ", mp->sq[i]->name,pp->houses); else (void)sprintf(cur_prop,"%s (H): ",mp->sq[i]->name); input[i] = get_int(cur_prop); temp[i] = pp->houses - input[i]; if (temp[i] < 0) { printf( "That's too many. The most you can sell is %d\n", pp->houses); goto over; } } if (mp->num_in == 3 && (abs(temp[0] - temp[1]) > 1 || abs(temp[0] - temp[2]) > 1 || abs(temp[1] - temp[2]) > 1)) { err: printf("That makes the spread too wide. Try again\n"); goto blew_it; } else if (mp->num_in == 2 && abs(temp[0] - temp[1]) > 1) goto err; for (tot = i = 0; i < mp->num_in; i++) tot += input[i]; if (tot) { printf("You asked to sell %d houses for $%d\n",tot,tot * price); if (getyn("Is that ok? ") == 0) { cur_p->money += tot * price; for (tot = i = 0; i < mp->num_in; i++) mp->sq[i]->desc->houses = temp[i]; } } } static void list_cur(mp) MON *mp; { int i; SQUARE *sqp; for (i = 0; i < mp->num_in; i++) { sqp = mp->sq[i]; if (sqp->desc->houses == 5) printf("%s (H) ", sqp->name); else printf("%s (%d) ", sqp->name, sqp->desc->houses); } putchar('\n'); } bsd-games-2.17/monop/monop.ext0000664000175000017500000000410110005547567015006 0ustar jsm28jsm28/* $NetBSD: monop.ext,v 1.7 2004/01/27 20:30:30 jsm Exp $ */ /*- * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)monop.ext 5.4 (Berkeley) 5/31/93 */ #include "deck.h" #include "monop.h" extern bool trading, spec, fixing, told_em; extern const char *const yncoms[], *const comlist[], *name_list[], *const lucky_mes[]; extern int num_play, player, num_doub, num_luck; extern void (*const func[])(void); extern DECK deck[2]; extern MON mon[]; extern PLAY *play, *cur_p; extern PROP prop[]; extern RR_S rr[]; extern SQUARE board[]; extern UTIL_S util[]; bsd-games-2.17/monop/prop.dat0000664000175000017500000000555607767741711014635 0ustar jsm28jsm28/* $NetBSD: prop.dat,v 1.3 2003/08/07 09:37:29 agc Exp $ */ /*- * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)prop.dat 5.4 (Berkeley) 5/31/93 */ /* morg monop square houses mon_desc rent */ {0, 0, 1, 0, &mon[0], { 2, 10, 30, 90, 160, 250} }, {0, 0, 3, 0, &mon[0], { 4, 20, 60, 180, 320, 450} }, {0, 0, 6, 0, &mon[1], { 6, 30, 90, 270, 400, 550} }, {0, 0, 7, 0, &mon[1], { 6, 30, 90, 270, 400, 550} }, {0, 0, 9, 0, &mon[1], { 8, 40,100, 300, 450, 600} }, {0, 0, 11, 0, &mon[2], {10, 50,150, 450, 625, 750} }, {0, 0, 13, 0, &mon[2], {10, 50,150, 450, 625, 750} }, {0, 0, 14, 0, &mon[2], {12, 60,180, 500, 700, 900} }, {0, 0, 16, 0, &mon[3], {14, 70,200, 550, 750, 950} }, {0, 0, 17, 0, &mon[3], {14, 70,200, 550, 750, 950} }, {0, 0, 19, 0, &mon[3], {16, 80,220, 600, 800,1000} }, {0, 0, 21, 0, &mon[4], {18, 90,250, 700, 875,1050} }, {0, 0, 23, 0, &mon[4], {18, 90,250, 700, 875,1050} }, {0, 0, 24, 0, &mon[4], {20,100,300, 750, 925,1100} }, {0, 0, 26, 0, &mon[5], {22,110,330, 800, 975,1150} }, {0, 0, 27, 0, &mon[5], {22,110,330, 800, 975,1150} }, {0, 0, 29, 0, &mon[5], {24,120,360, 850,1025,1200} }, {0, 0, 31, 0, &mon[6], {26,130,390, 900,1100,1275} }, {0, 0, 32, 0, &mon[6], {26,130,390, 900,1100,1275} }, {0, 0, 34, 0, &mon[6], {28,150,450,1000,1200,1400} }, {0, 0, 37, 0, &mon[7], {35,175,500,1100,1300,1500} }, {0, 0, 39, 0, &mon[7], {50,200,600,1400,1700,2000} } bsd-games-2.17/monop/malloc.c0000664000175000017500000003163310162527625014556 0ustar jsm28jsm28/* $NetBSD: malloc.c,v 1.4 2004/12/14 00:21:01 nathanw Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #if defined(LIBC_SCCS) && !defined(lint) #if 0 static char sccsid[] = "@(#)malloc.c 8.1 (Berkeley) 6/4/93"; #else __RCSID("$NetBSD: malloc.c,v 1.4 2004/12/14 00:21:01 nathanw Exp $"); #endif #endif /* LIBC_SCCS and not lint */ /* * malloc.c (Caltech) 2/21/82 * Chris Kingsley, kingsley@cit-20. * * This is a very fast storage allocator. It allocates blocks of a small * number of different sizes, and keeps free lists of each size. Blocks that * don't exactly fit are passed up to the next larger size. In this * implementation, the available sizes are 2^n-4 (or 2^n-10) bytes long. * This is designed for use in a virtual memory environment. */ #include #if defined(DEBUG) || defined(RCHECK) #include #endif #if defined(RCHECK) || defined(MSTATS) #include #endif #include #include #include #include /* * The overhead on a block is at least 4 bytes. When free, this space * contains a pointer to the next free block, and the bottom two bits must * be zero. When in use, the first byte is set to MAGIC, and the second * byte is the size index. The remaining bytes are for alignment. * If range checking is enabled then a second word holds the size of the * requested block, less 1, rounded up to a multiple of sizeof(RMAGIC). * The order of elements is critical: ov_magic must overlay the low order * bits of ov_next, and ov_magic can not be a valid ov_next bit pattern. */ union overhead { union overhead *ov_next; /* when free */ struct { u_char ovu_magic; /* magic number */ u_char ovu_index; /* bucket # */ #ifdef RCHECK u_short ovu_rmagic; /* range magic number */ u_long ovu_size; /* actual block size */ #endif } ovu; #define ov_magic ovu.ovu_magic #define ov_index ovu.ovu_index #define ov_rmagic ovu.ovu_rmagic #define ov_size ovu.ovu_size }; #define MAGIC 0xef /* magic # on accounting info */ #ifdef RCHECK #define RMAGIC 0x5555 /* magic # on range info */ #endif #ifdef RCHECK #define RSLOP sizeof (u_short) #else #define RSLOP 0 #endif /* * nextf[i] is the pointer to the next free block of size 2^(i+3). The * smallest allocatable block is 8 bytes. The overhead information * precedes the data area returned to the user. */ #define NBUCKETS 30 static union overhead *nextf[NBUCKETS]; static long pagesz; /* page size */ static int pagebucket; /* page size bucket */ #ifdef MSTATS /* * nmalloc[i] is the difference between the number of mallocs and frees * for a given block size. */ static u_int nmalloc[NBUCKETS]; #endif static pthread_mutex_t malloc_mutex = PTHREAD_MUTEX_INITIALIZER; static void morecore(int); static int findbucket(union overhead *, int); #ifdef MSTATS void mstats(const char *); #endif #if defined(DEBUG) || defined(RCHECK) #define ASSERT(p) if (!(p)) botch(__STRING(p)) static void botch(const char *); /* * NOTE: since this may be called while malloc_mutex is locked, stdio must not * be used in this function. */ static void botch(s) const char *s; { struct iovec iov[3]; iov[0].iov_base = "\nassertion botched: "; iov[0].iov_len = 20; iov[1].iov_base = (void *)s; iov[1].iov_len = strlen(s); iov[2].iov_base = "\n"; iov[2].iov_len = 1; /* * This place deserves a word of warning: a cancellation point will * occur when executing writev(), and we might be still owning * malloc_mutex. At this point we need to disable cancellation * until `after' abort() because i) establishing a cancellation handler * might, depending on the implementation, result in another malloc() * to be executed, and ii) it is really not desirable to let execution * continue. `Fix me.' * * Note that holding mutex_lock during abort() is safe. */ (void)writev(STDERR_FILENO, iov, 3); abort(); } #else #define ASSERT(p) #endif void * malloc(nbytes) size_t nbytes; { union overhead *op; int bucket; long n; unsigned amt; pthread_mutex_lock(&malloc_mutex); /* * First time malloc is called, setup page size and * align break pointer so all data will be page aligned. */ if (pagesz == 0) { pagesz = n = getpagesize(); ASSERT(pagesz > 0); op = (union overhead *)(void *)sbrk(0); n = n - sizeof (*op) - ((long)op & (n - 1)); if (n < 0) n += pagesz; if (n) { if (sbrk((int)n) == (void *)-1) { pthread_mutex_unlock(&malloc_mutex); return (NULL); } } bucket = 0; amt = 8; while (pagesz > amt) { amt <<= 1; bucket++; } pagebucket = bucket; } /* * Convert amount of memory requested into closest block size * stored in hash buckets which satisfies request. * Account for space used per block for accounting. */ if (nbytes <= (n = pagesz - sizeof (*op) - RSLOP)) { #ifndef RCHECK amt = 8; /* size of first bucket */ bucket = 0; #else amt = 16; /* size of first bucket */ bucket = 1; #endif n = -((long)sizeof (*op) + RSLOP); } else { amt = (unsigned)pagesz; bucket = pagebucket; } while (nbytes > amt + n) { amt <<= 1; if (amt == 0) return (NULL); bucket++; } /* * If nothing in hash bucket right now, * request more memory from the system. */ if ((op = nextf[bucket]) == NULL) { morecore(bucket); if ((op = nextf[bucket]) == NULL) { pthread_mutex_unlock(&malloc_mutex); return (NULL); } } /* remove from linked list */ nextf[bucket] = op->ov_next; op->ov_magic = MAGIC; op->ov_index = bucket; #ifdef MSTATS nmalloc[bucket]++; #endif pthread_mutex_unlock(&malloc_mutex); #ifdef RCHECK /* * Record allocated size of block and * bound space with magic numbers. */ op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1); op->ov_rmagic = RMAGIC; *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC; #endif return ((void *)(op + 1)); } /* * Allocate more memory to the indicated bucket. */ static void morecore(bucket) int bucket; { union overhead *op; long sz; /* size of desired block */ long amt; /* amount to allocate */ long nblks; /* how many blocks we get */ /* * sbrk_size <= 0 only for big, FLUFFY, requests (about * 2^30 bytes on a VAX, I think) or for a negative arg. */ sz = 1 << (bucket + 3); #ifdef DEBUG ASSERT(sz > 0); #else if (sz <= 0) return; #endif if (sz < pagesz) { amt = pagesz; nblks = amt / sz; } else { amt = sz + pagesz; nblks = 1; } op = (union overhead *)(void *)sbrk((int)amt); /* no more room! */ if ((long)op == -1) return; /* * Add new memory allocated to that on * free list for this hash bucket. */ nextf[bucket] = op; while (--nblks > 0) { op->ov_next = (union overhead *)(void *)((caddr_t)(void *)op+(size_t)sz); op = op->ov_next; } } void free(cp) void *cp; { long size; union overhead *op; if (cp == NULL) return; op = (union overhead *)(void *)((caddr_t)cp - sizeof (union overhead)); #ifdef DEBUG ASSERT(op->ov_magic == MAGIC); /* make sure it was in use */ #else if (op->ov_magic != MAGIC) return; /* sanity */ #endif #ifdef RCHECK ASSERT(op->ov_rmagic == RMAGIC); ASSERT(*(u_short *)((caddr_t)(op + 1) + op->ov_size) == RMAGIC); #endif size = op->ov_index; ASSERT(size < NBUCKETS); pthread_mutex_lock(&malloc_mutex); op->ov_next = nextf[(unsigned int)size];/* also clobbers ov_magic */ nextf[(unsigned int)size] = op; #ifdef MSTATS nmalloc[(size_t)size]--; #endif pthread_mutex_unlock(&malloc_mutex); } /* * When a program attempts "storage compaction" as mentioned in the * old malloc man page, it realloc's an already freed block. Usually * this is the last block it freed; occasionally it might be farther * back. We have to search all the free lists for the block in order * to determine its bucket: 1st we make one pass thru the lists * checking only the first block in each; if that fails we search * ``__realloc_srchlen'' blocks in each list for a match (the variable * is extern so the caller can modify it). If that fails we just copy * however many bytes was given to realloc() and hope it's not huge. */ int __realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */ void * realloc(cp, nbytes) void *cp; size_t nbytes; { u_long onb; long i; union overhead *op; char *res; int was_alloced = 0; if (cp == NULL) return (malloc(nbytes)); if (nbytes == 0) { free (cp); return (NULL); } op = (union overhead *)(void *)((caddr_t)cp - sizeof (union overhead)); pthread_mutex_lock(&malloc_mutex); if (op->ov_magic == MAGIC) { was_alloced++; i = op->ov_index; } else { /* * Already free, doing "compaction". * * Search for the old block of memory on the * free list. First, check the most common * case (last element free'd), then (this failing) * the last ``__realloc_srchlen'' items free'd. * If all lookups fail, then assume the size of * the memory block being realloc'd is the * largest possible (so that all "nbytes" of new * memory are copied into). Note that this could cause * a memory fault if the old area was tiny, and the moon * is gibbous. However, that is very unlikely. */ if ((i = findbucket(op, 1)) < 0 && (i = findbucket(op, __realloc_srchlen)) < 0) i = NBUCKETS; } onb = (u_long)1 << (u_long)(i + 3); if (onb < pagesz) onb -= sizeof (*op) + RSLOP; else onb += pagesz - sizeof (*op) - RSLOP; /* avoid the copy if same size block */ if (was_alloced) { if (i) { i = (long)1 << (long)(i + 2); if (i < pagesz) i -= sizeof (*op) + RSLOP; else i += pagesz - sizeof (*op) - RSLOP; } if (nbytes <= onb && nbytes > i) { #ifdef RCHECK op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1); *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC; #endif pthread_mutex_unlock(&malloc_mutex); return (cp); } #ifndef _REENT else free(cp); #endif } pthread_mutex_unlock(&malloc_mutex); if ((res = malloc(nbytes)) == NULL) { #ifdef _REENT free(cp); #endif return (NULL); } #ifndef _REENT if (cp != res) /* common optimization if "compacting" */ (void)memmove(res, cp, (size_t)((nbytes < onb) ? nbytes : onb)); #else (void)memmove(res, cp, (size_t)((nbytes < onb) ? nbytes : onb)); free(cp); #endif return (res); } /* * Search ``srchlen'' elements of each free list for a block whose * header starts at ``freep''. If srchlen is -1 search the whole list. * Return bucket number, or -1 if not found. */ static int findbucket(freep, srchlen) union overhead *freep; int srchlen; { union overhead *p; int i, j; for (i = 0; i < NBUCKETS; i++) { j = 0; for (p = nextf[i]; p && j != srchlen; p = p->ov_next) { if (p == freep) return (i); j++; } } return (-1); } #ifdef MSTATS /* * mstats - print out statistics about malloc * * Prints two lines of numbers, one showing the length of the free list * for each size category, the second showing the number of mallocs - * frees for each size category. */ void mstats(s) char *s; { int i, j; union overhead *p; int totfree = 0, totused = 0; fprintf(stderr, "Memory allocation statistics %s\nfree:\t", s); for (i = 0; i < NBUCKETS; i++) { for (j = 0, p = nextf[i]; p; p = p->ov_next, j++) ; fprintf(stderr, " %d", j); totfree += j * (1 << (i + 3)); } fprintf(stderr, "\nused:\t"); for (i = 0; i < NBUCKETS; i++) { fprintf(stderr, " %d", nmalloc[i]); totused += nmalloc[i] * (1 << (i + 3)); } fprintf(stderr, "\n\tTotal in use: %d, total free: %d\n", totused, totfree); } #endif bsd-games-2.17/monop/rent.c0000664000175000017500000000560207767741711014267 0ustar jsm28jsm28/* $NetBSD: rent.c,v 1.6 2003/08/07 09:37:29 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)rent.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: rent.c,v 1.6 2003/08/07 09:37:29 agc Exp $"); #endif #endif /* not lint */ #include "monop.ext" /* * This routine has the player pay rent */ void rent(sqp) SQUARE *sqp; { int rnt = 0; PROP *pp; PLAY *plp; plp = &play[sqp->owner]; printf("Owned by %s\n", plp->name); if (sqp->desc->morg) { lucky("The thing is mortgaged. "); return; } switch (sqp->type) { case PRPTY: pp = sqp->desc; if (pp->monop) if (pp->houses == 0) printf("rent is %d\n", rnt=pp->rent[0] * 2); else if (pp->houses < 5) printf("with %d houses, rent is %d\n", pp->houses, rnt=pp->rent[pp->houses]); else printf("with a hotel, rent is %d\n", rnt=pp->rent[pp->houses]); else printf("rent is %d\n", rnt = pp->rent[0]); break; case RR: rnt = 25; rnt <<= (plp->num_rr - 1); if (spec) rnt <<= 1; printf("rent is %d\n", rnt); break; case UTIL: rnt = roll(2, 6); if (plp->num_util == 2 || spec) { printf("rent is 10 * roll (%d) = %d\n", rnt, rnt * 10); rnt *= 10; } else { printf("rent is 4 * roll (%d) = %d\n", rnt, rnt * 4); rnt *= 4; } break; } cur_p->money -= rnt; plp->money += rnt; } bsd-games-2.17/monop/roll.c0000664000175000017500000000453207767741711014270 0ustar jsm28jsm28/* $NetBSD: roll.c,v 1.9 2003/08/07 09:37:29 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: roll.c,v 1.9 2003/08/07 09:37:29 agc Exp $"); #endif #endif /* not lint */ #include "monop.ext" #include /* * This routine rolls ndie nside-sided dice. */ #if defined(pdp11) #define MAXRAND 32767L int roll(ndie, nsides) int ndie, nsides; { long tot; unsigned n, r; tot = 0; n = ndie; while (n--) tot += rand(); return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie; } #else int roll(ndie, nsides) int ndie, nsides; { int tot, r; double num_sides; num_sides = nsides; tot = 0; while (ndie--) tot += (r = rand()) * (num_sides / RAND_MAX) + 1; return tot; } #endif bsd-games-2.17/monop/deck.h0000664000175000017500000000402207767741711014225 0ustar jsm28jsm28/* $NetBSD: deck.h,v 1.6 2003/08/07 09:37:27 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)deck.h 8.1 (Berkeley) 5/31/93 */ #include #define bool char #define CC_D deck[0] #define CH_D deck[1] struct dk_st { /* deck description structure */ int num_cards; /* number of cards in deck */ int last_card; /* number of last card picked */ bool gojf_used; /* set if gojf card out of deck */ u_int64_t *offsets; /* offsets for start of cards */ }; typedef struct dk_st DECK; bsd-games-2.17/monop/mon.dat0000664000175000017500000000416007767741711014434 0ustar jsm28jsm28/* $NetBSD: mon.dat,v 1.3 2003/08/07 09:37:28 agc Exp $ */ /*- * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mon.dat 5.4 (Berkeley) 5/31/93 */ /* name owner num_in num_own h_cost not_m mon_n sq */ {0, -1, 2, 0, 1, "Purple", "PURPLE", {1,3}}, {0, -1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6,8,9}}, {0, -1, 3, 0, 2, "Violet", "VIOLET", {11,13,14}}, {0, -1, 3, 0, 2, "Orange", "ORANGE", {16,18,19}}, {0, -1, 3, 0, 3, "Red", "RED", {21,23,24}}, {0, -1, 3, 0, 3, "Yellow", "YELLOW", {26,27,29}}, {0, -1, 3, 0, 4, "Green", "GREEN", {31,32,34}}, {0, -1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37,39}} bsd-games-2.17/monop/jail.c0000664000175000017500000000666207767741711014245 0ustar jsm28jsm28/* $NetBSD: jail.c,v 1.6 2003/08/07 09:37:28 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)jail.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: jail.c,v 1.6 2003/08/07 09:37:28 agc Exp $"); #endif #endif /* not lint */ #include "monop.ext" /* * This routine uses a get-out-of-jail-free card to get the * player out of jail. */ void card() { if (cur_p->loc != JAIL) { printf("But you're not IN Jail\n"); return; } if (cur_p->num_gojf == 0) { printf("But you don't HAVE a get out of jail free card\n"); return; } ret_card(cur_p); cur_p->loc = 10; /* just visiting */ cur_p->in_jail = 0; } /* * This routine returns the players get-out-of-jail-free card * to a deck. */ void ret_card(plr) PLAY *plr; { plr->num_gojf--; if (CC_D.gojf_used) CC_D.gojf_used = FALSE; else CH_D.gojf_used = FALSE; } /* * This routine deals with paying your way out of jail. */ void pay() { if (cur_p->loc != JAIL) { printf("But you're not IN Jail\n"); return; } cur_p->loc = 10; cur_p->money -= 50; cur_p->in_jail = 0; printf("That cost you $50\n"); } /* * This routine deals with a move in jail */ int move_jail(r1, r2) int r1, r2; { if (r1 != r2) { printf("Sorry, that doesn't get you out\n"); if (++(cur_p->in_jail) == 3) { printf("It's your third turn and you didn't roll " "doubles. You have to pay $50\n"); cur_p->money -= 50; moveit: cur_p->loc = 10; cur_p->in_jail = 0; move(r1+r2); r1 = r2 - 1; /* kludge: stop new roll w/doub */ return TRUE; } return FALSE; } else { printf("Double roll gets you out.\n"); goto moveit; } } void printturn() { if (cur_p->loc != JAIL) return; printf("(This is your "); switch (cur_p->in_jail) { case 0: printf("1st"); break; case 1: printf("2nd"); break; case 2: printf("3rd (and final)"); break; } printf(" turn in JAIL)\n"); } bsd-games-2.17/monop/monop.6.in0000664000175000017500000001422007767741711014773 0ustar jsm28jsm28.\" $NetBSD: monop.6,v 1.16 2003/08/07 09:37:28 agc Exp $ .\" .\" Copyright (c) 1980 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)monop.6 6.5 (Berkeley) 3/25/93 .\" .Dd March 25, 1993 .Dt MONOP 6 .Os .Sh NAME .Nm monop .Nd Monopoly game .Sh SYNOPSIS .Nm .Op Ar file .Sh DESCRIPTION .Nm is reminiscent of the Parker Brother's game Monopoly, and monitors a game between 1 to 9 users. It is assumed that the rules of Monopoly are known. The game follows the standard rules, with the exception that, if a property goes up for auction and there are only two solvent players, no auction is held and the property remains unowned. .Nm The game, in effect, lends the player money, so it is possible to buy something which you cannot afford. However, as soon as a person goes into debt, he must .Dq fix the problem , i.e., make himself solvent, before play can continue. If this is not possible, the player's property reverts to his debtee, either a player or the bank. A player can resign at any time to any person or the bank, which puts the property back on the board, unowned. .Pp Any time that the response to a question is a .Em string , e.g., a name, place or person, you can type .Sq Ic \&? to get a list of valid answers. It is not possible to input a negative number, nor is it ever necessary. .Pp .Em A Summary of Commands : .Bl -tag -width item .It Ic quit quit game: This allows you to quit the game. It asks you if you're sure. .It Ic print print board: This prints out the current board. The columns have the following meanings (column headings are the same for the .Ic where , .Ic own holdings , and .Ic holdings commands): .Pp .Bl -tag -width indent -compact .It Name The first ten characters of the name of the square. .It Own The .Em number of the owner of the property. .It Price The cost of the property (if any). .It Mg This field has a .Sq * in it if the property is mortgaged. .It \&# If the property is a Utility or Railroad, this is the number of such owned by the owner. If the property is land, this is the number of houses on it. .It Rent Current rent on the property. If it is not owned, there is no rent. .El .It Ic where where players are: Tells you where all the players are. A .Sq * indicates the current player. .It Ic own holdings List your own holdings, i.e., money, get-out-of-jail-free cards, and property. .It Ic holdings holdings list: Look at anyone's holdings. It will ask you whose holdings you wish to look at. When you are finished, type .Sq Ic done . .It Ic mortgage mortgage property: Sets up a list of mortgageable property, and asks which you wish to mortgage. .It Ic unmortgage unmortgage property: Unmortgage mortgaged property. .It Ic buy buy houses: Sets up a list of monopolies on which you can buy houses. If there is more than one, it asks you which you want to buy for. It then asks you how many for each piece of property, giving the current amount in parentheses after the property name. If you build in an unbalanced manner (a disparity of more than one house within the same monopoly), it asks you to re-input things. .It Ic sell sell houses: Sets up a list of monopolies from which you can sell houses. It operates in an analogous manner to .Ic buy . .It Ic card card for jail: Use a get-out-of-jail-free card to get out of jail. If you're not in jail, or you don't have one, it tells you so. .It Ic pay pay for jail: Pay $50 to get out of jail, from whence you are put on Just Visiting. Difficult to do if you're not there. .It Ic trade This allows you to trade with another player. It asks you whom you wish to trade with, and then asks you what each wishes to give up. You can get a summary at the end, and, in all cases, it asks for confirmation of the trade before doing it. .It Ic resign Resign to another player or the bank. If you resign to the bank, all property reverts to its virgin state, and get-out-of-jail-free cards revert to the deck. .It Ic save save game: Save the current game in a file for later play. You can continue play after saving, either by adding the file in which you saved the game after the .Nm command, or by using the .Ic restore command (see below). It will ask you which file you wish to save it in, and, if the file exists, confirm that you wish to overwrite it. .It Ic restore restore game: Read in a previously saved game from a file. It leaves the file intact. .It Ic roll Roll the dice and move forward to your new location. If you simply hit the .Aq RETURN key instead of a command, it is the same as typing .Ic roll . .El .Sh AUTHOR .An Ken Arnold .Sh FILES .Bl -tag -width @monop_cardsfile@ -compact .It Pa @monop_cardsfile@ Chance and Community Chest cards .El .Sh BUGS No command can be given an argument instead of a response to a query. bsd-games-2.17/monop/prop.c0000664000175000017500000001212710005547567014267 0ustar jsm28jsm28/* $NetBSD: prop.c,v 1.9 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)prop.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: prop.c,v 1.9 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include #include "monop.ext" static int value(SQUARE *); /* * This routine deals with buying property, setting all the * appropriate flags. */ void buy(player, sqrp) int player; SQUARE *sqrp; { trading = FALSE; sqrp->owner = player; add_list(player, &(play[player].own_list), cur_p->loc); } /* * This routine adds an item to the list. */ void add_list(plr, head, op_sqr) int plr; OWN **head; int op_sqr; { int val; OWN *tp, *last_tp; OWN *op; op = (OWN *)calloc(1, sizeof (OWN)); if (op == NULL) errx(1, "out of memory"); op->sqr = &board[op_sqr]; val = value(op->sqr); last_tp = NULL; for (tp = *head; tp && value(tp->sqr) < val; tp = tp->next) if (val == value(tp->sqr)) { free(op); return; } else last_tp = tp; op->next = tp; if (last_tp != NULL) last_tp->next = op; else *head = op; if (!trading) set_ownlist(plr); } /* * This routine deletes property from the list. */ void del_list(plr, head, op_sqr) int plr; OWN **head; short op_sqr; { OWN *op, *last_op; switch (board[op_sqr].type) { case PRPTY: board[op_sqr].desc->mon_desc->num_own--; break; case RR: play[plr].num_rr--; break; case UTIL: play[plr].num_util--; break; } last_op = NULL; for (op = *head; op; op = op->next) if (op->sqr == &board[op_sqr]) break; else last_op = op; if (last_op == NULL) *head = op->next; else { last_op->next = op->next; free(op); } } /* * This routine calculates the value for sorting of the * given square. */ static int value(sqp) SQUARE *sqp; { int sqr; sqr = sqnum(sqp); switch (sqp->type) { case SAFE: return 0; default: /* Specials, etc */ return 1; case UTIL: if (sqr == 12) return 2; else return 3; case RR: return 4 + sqr/10; case PRPTY: return 8 + (sqp->desc) - prop; } } /* * This routine accepts bids for the current peice * of property. */ void bid() { static bool in[MAX_PL]; int i, num_in, cur_max; char buf[80]; int cur_bid; printf("\nSo it goes up for auction. Type your bid after your name\n"); for (i = 0; i < num_play; i++) in[i] = TRUE; i = -1; cur_max = 0; num_in = num_play; while (num_in > 1 || (cur_max == 0 && num_in > 0)) { i = (i + 1) % num_play; if (in[i]) { do { (void)sprintf(buf, "%s: ", name_list[i]); cur_bid = get_int(buf); if (cur_bid == 0) { in[i] = FALSE; if (--num_in == 0) break; } else if (cur_bid <= cur_max) { printf("You must bid higher than %d " "to stay in\n", cur_max); printf("(bid of 0 drops you out)\n"); } } while (cur_bid != 0 && cur_bid <= cur_max); cur_max = (cur_bid ? cur_bid : cur_max); } } if (cur_max != 0) { while (!in[i]) i = (i + 1) % num_play; printf("It goes to %s (%d) for $%d\n",play[i].name,i+1,cur_max); buy(i, &board[cur_p->loc]); play[i].money -= cur_max; } else printf("Nobody seems to want it, so we'll leave it for " "later\n"); } /* * This routine calculates the value of the property * of given player. */ int prop_worth(plp) PLAY *plp; { OWN *op; int worth; worth = 0; for (op = plp->own_list; op; op = op->next) { if (op->sqr->type == PRPTY && op->sqr->desc->monop) worth += op->sqr->desc->mon_desc->h_cost * 50 * op->sqr->desc->houses; worth += op->sqr->cost; } return worth; } bsd-games-2.17/monop/getinp.c0000664000175000017500000000651510155330535014570 0ustar jsm28jsm28/* $NetBSD: getinp.c,v 1.13 2004/11/05 21:30:32 dsl Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)getinp.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: getinp.c,v 1.13 2004/11/05 21:30:32 dsl Exp $"); #endif #endif /* not lint */ #include #include #include #include "monop.ext" #define LINE 70 static char buf[257]; static int comp(const char *); int getinp(prompt, list) const char *prompt, *const list[]; { int i, n_match, match = 0; char *sp; int c; for (;;) { inter: printf("%s", prompt); for (sp = buf; (c=getchar()) != '\n'; ) { *sp = c; if (c == -1) /* check for interrupted system call */ goto inter; else if (sp != buf || *sp != ' ') sp++; } *sp = c; if (buf[0] == '?' && buf[1] == '\n') { printf("Valid inputs are: "); for (i = 0, match = 18; list[i]; i++) { if ((match+=(n_match=strlen(list[i]))) > LINE) { printf("\n\t"); match = n_match + 8; } if (*list[i] == '\0') { match += 8; printf(""); } else printf("%s", list[i]); if (list[i+1]) printf(", "); else putchar('\n'); match += 2; } continue; } *sp = '\0'; for (sp = buf; *sp; sp++) *sp = tolower((unsigned char)*sp); for (i = n_match = 0; list[i]; i++) if (comp(list[i])) { n_match++; match = i; } if (n_match == 1) return match; else if (buf[0] != '\0') printf("Illegal response: \"%s\". " "Use '?' to get list of valid answers\n", buf); } } static int comp(s1) const char *s1; { const char *sp, *tsp; char c; if (buf[0] != '\0') for (sp = buf, tsp = s1; *sp; ) { c = tolower((unsigned char)*tsp); tsp++; if (c != *sp++) return 0; } else if (*s1 != '\0') return 0; return 1; } bsd-games-2.17/monop/monop.c0000664000175000017500000001165710005547567014446 0ustar jsm28jsm28/* $NetBSD: monop.c,v 1.15 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: monop.c,v 1.15 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include #include #include #include #include "monop.def" int main(int, char *[]); static void getplayers(void); static void init_players(void); static void init_monops(void); static void do_quit(int); void *heapstart; /* * This program implements a monopoly game */ int main(ac, av) int ac; char *av[]; { /* Revoke setgid privileges */ setregid(getgid(), getgid()); srand(getpid()); heapstart = sbrk(0); if (ac > 1) { if (!rest_f(av[1])) restore(); } else { getplayers(); init_players(); init_monops(); } num_luck = sizeof lucky_mes / sizeof (char *); init_decks(); signal(SIGINT, do_quit); for (;;) { printf("\n%s (%d) (cash $%d) on %s\n", cur_p->name, player + 1, cur_p->money, board[cur_p->loc].name); printturn(); force_morg(); execute(getinp("-- Command: ", comlist)); } } /*ARGSUSED*/ static void do_quit(n) int n __attribute__((__unused__)); { quit(); } /* * This routine gets the names of the players */ static void getplayers() { char *sp; int i, j; char buf[257]; blew_it: for (;;) { if ((num_play=get_int("How many players? ")) <= 0 || num_play > MAX_PL) printf("Sorry. Number must range from 1 to 9\n"); else break; } cur_p = play = (PLAY *) calloc(num_play, sizeof (PLAY)); if (play == NULL) err(1, NULL); for (i = 0; i < num_play; i++) { over: printf("Player %d's name: ", i + 1); for (sp = buf; (*sp=getchar()) != '\n'; sp++) continue; if (sp == buf) goto over; *sp++ = '\0'; name_list[i] = play[i].name = (char *)calloc(1, sp - buf); if (name_list[i] == NULL) err(1, NULL); strcpy(play[i].name, buf); play[i].money = 1500; } name_list[i++] = "done"; name_list[i] = 0; for (i = 0; i < num_play; i++) for (j = i + 1; j < num_play; j++) if (strcasecmp(name_list[i], name_list[j]) == 0) { if (i != num_play - 1) printf("Hey!!! Some of those are " "IDENTICAL!! Let's try that " "again....\n"); else printf("\"done\" is a reserved word. " "Please try again\n"); for (i = 0; i < num_play; i++) free(play[i].name); free(play); goto blew_it; } } /* * This routine figures out who goes first */ static void init_players() { int i, rl, cur_max; bool over = 0; int max_pl = 0; again: putchar('\n'); for (cur_max = i = 0; i < num_play; i++) { printf("%s (%d) rolls %d\n", play[i].name, i+1, rl=roll(2, 6)); if (rl > cur_max) { over = FALSE; cur_max = rl; max_pl = i; } else if (rl == cur_max) over++; } if (over) { printf("%d people rolled the same thing, so we'll try again\n", over + 1); goto again; } player = max_pl; cur_p = &play[max_pl]; printf("%s (%d) goes first\n", cur_p->name, max_pl + 1); } /* * This routine initializes the monopoly structures. */ static void init_monops() { MON *mp; int i; for (mp = mon; mp < &mon[N_MON]; mp++) { mp->name = mp->not_m; for (i = 0; i < mp->num_in; i++) mp->sq[i] = &board[mp->sqnums[i]]; } } bsd-games-2.17/monop/initdeck.c0000664000175000017500000001473507767741711015120 0ustar jsm28jsm28/* $NetBSD: initdeck.c,v 1.15 2003/08/07 09:37:28 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef __NetBSD__ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)initdeck.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: initdeck.c,v 1.15 2003/08/07 09:37:28 agc Exp $"); #endif #endif /* not lint */ #endif /* __NetBSD__ */ #include #include #include #include #include "deck.h" #ifndef u_int32_t #define u_int32_t unsigned int #endif static u_int32_t h2nl(u_int32_t h) { unsigned char c[4]; u_int32_t rv; c[0] = (h >> 24) & 0xff; c[1] = (h >> 16) & 0xff; c[2] = (h >> 8) & 0xff; c[3] = (h >> 0) & 0xff; memcpy(&rv, c, sizeof rv); return (rv); } /* * This program initializes the card files for monopoly. * It reads in a data file with Com. Chest cards, followed by * the Chance card. The two are separated by a line of "%-". * All other cards are separated by lines of "%%". In the front * of the file is the data for the decks in the same order. * This includes the seek pointer for the start of each card. * All cards start with their execution code, followed by the * string to print, terminated with a null byte. */ #define TRUE 1 #define FALSE 0 #define bool char const char *infile = "cards.inp", /* input file */ *outfile = "cards.pck"; /* "packed" file */ DECK deck[2]; FILE *inf, *outf; /* initdeck.c */ int main(int, char *[]); static void getargs(int, char *[]); static void fwrite_be_offt(off_t, FILE *); static void count(void); static void putem(void); int main(ac, av) int ac; char *av[]; { int i, nc; /* sanity test */ if (sizeof(int) != 4) { fprintf(stderr, "sizeof(int) != 4\n"); exit(1); } getargs(ac, av); if ((inf = fopen(infile, "r")) == NULL) { perror(infile); exit(1); } count(); /* * allocate space for pointers. */ CC_D.offsets = calloc(CC_D.num_cards + 1, /* sizeof (off_t) */ 8); CH_D.offsets = calloc(CH_D.num_cards + 1, /* sizeof (off_t) */ 8); if (CC_D.offsets == NULL || CH_D.offsets == NULL) { fprintf(stderr, "out of memory\n"); exit(1); } fseek(inf, 0L, SEEK_SET); if ((outf = fopen(outfile, "w")) == NULL) { perror(outfile); exit(1); } /* * these fields will be overwritten after the offsets are calculated, * so byte-order doesn't matter yet. */ fwrite(&nc, sizeof(nc), 1, outf); fwrite(&nc, sizeof(nc), 1, outf); fwrite(CC_D.offsets, /* sizeof (off_t) */ 8, CC_D.num_cards, outf); fwrite(CH_D.offsets, /* sizeof (off_t) */ 8, CH_D.num_cards, outf); /* * write out the cards themselves (calculating the offsets). */ putem(); fclose(inf); fseek(outf, 0, SEEK_SET); /* number of community chest cards first... */ nc = h2nl(CC_D.num_cards); fwrite(&nc, sizeof(nc), 1, outf); /* ... then number of chance cards. */ nc = h2nl(CH_D.num_cards); fwrite(&nc, sizeof(nc), 1, outf); /* dump offsets in big-endian byte order */ for (i = 0; i < CC_D.num_cards; i++) fwrite_be_offt(CC_D.offsets[i], outf); for (i = 0; i < CH_D.num_cards; i++) fwrite_be_offt(CH_D.offsets[i], outf); fflush(outf); if (ferror(outf)) { perror(outfile); exit(1); } fclose(outf); printf("There were %d com. chest and %d chance cards\n", CC_D.num_cards, CH_D.num_cards); exit(0); } static void getargs(ac, av) int ac; char *av[]; { if (ac > 1) infile = av[1]; if (ac > 2) outfile = av[2]; } /* * count the cards */ static void count() { bool newline; DECK *in_deck; int c; newline = TRUE; in_deck = &CC_D; while ((c=getc(inf)) != EOF) if (newline && c == '%') { newline = FALSE; in_deck->num_cards++; if (getc(inf) == '-') in_deck = &CH_D; } else newline = (c == '\n'); in_deck->num_cards++; } /* * put strings in the file */ static void putem() { bool newline; DECK *in_deck; int c; int num; in_deck = &CC_D; CC_D.num_cards = 1; CH_D.num_cards = 0; CC_D.offsets[0] = ftell(outf); putc(getc(inf), outf); putc(getc(inf), outf); for (num = 0; (c=getc(inf)) != '\n'; ) num = num * 10 + (c - '0'); putw(h2nl(num), outf); newline = FALSE; while ((c=getc(inf)) != EOF) if (newline && c == '%') { putc('\0', outf); newline = FALSE; if (getc(inf) == '-') in_deck = &CH_D; while (getc(inf) != '\n') continue; in_deck->offsets[in_deck->num_cards++] = ftell(outf); if ((c=getc(inf)) == EOF) break; putc(c, outf); putc(c = getc(inf), outf); for (num = 0; (c=getc(inf)) != EOF && c != '\n'; ) num = num * 10 + (c - '0'); putw(h2nl(num), outf); } else { putc(c, outf); newline = (c == '\n'); } putc('\0', outf); } /* * fwrite_be_offt: * Write out the off paramater as a 64 bit big endian number */ static void fwrite_be_offt(off, f) off_t off; FILE *f; { int i; unsigned char c[8]; for (i = 7; i >= 0; i--) { c[i] = off & 0xff; off >>= 8; } fwrite(c, sizeof(c), 1, f); } bsd-games-2.17/monop/cards.c0000664000175000017500000001334510005547567014406 0ustar jsm28jsm28/* $NetBSD: cards.c,v 1.14 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: cards.c,v 1.14 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include #include #include "monop.ext" #include "pathnames.h" /* * These routine deal with the card decks */ #define GOJF 'F' /* char for get-out-of-jail-free cards */ #ifndef DEV static const char *cardfile = _PATH_CARDS; #else static const char *cardfile = "cards.pck"; #endif static FILE *deckf; static void set_up(DECK *); static void printmes(void); /* * This routine initializes the decks from the data file, * which it opens. */ void init_decks() { int32_t nc; if ((deckf=fopen(cardfile, "r")) == NULL) { file_err: perror(cardfile); exit(1); } /* read number of community chest cards... */ if (fread(&nc, sizeof(nc), 1, deckf) != 1) goto file_err; CC_D.num_cards = be32toh(nc); /* ... and number of community chest cards. */ if (fread(&nc, sizeof(nc), 1, deckf) != 1) goto file_err; CH_D.num_cards = be32toh(nc); set_up(&CC_D); set_up(&CH_D); } /* * This routine sets up the offset pointers for the given deck. */ static void set_up(dp) DECK *dp; { int r1, r2; int i; dp->offsets = (u_int64_t *) calloc(dp->num_cards, sizeof (u_int64_t)); if (dp->offsets == NULL) err(1, NULL); if (fread(dp->offsets, sizeof(u_int64_t), dp->num_cards, deckf) != (size_t)dp->num_cards) { perror(cardfile); exit(1); } /* convert offsets from big-endian byte order */ for (i = 0; i < dp->num_cards; i++) BE64TOH(dp->offsets[i]); dp->last_card = 0; dp->gojf_used = FALSE; for (i = 0; i < dp->num_cards; i++) { u_int64_t temp; r1 = roll(1, dp->num_cards) - 1; r2 = roll(1, dp->num_cards) - 1; temp = dp->offsets[r2]; dp->offsets[r2] = dp->offsets[r1]; dp->offsets[r1] = temp; } } /* * This routine draws a card from the given deck */ void get_card(dp) DECK *dp; { char type_maj, type_min; int num; int i, per_h, per_H, num_h, num_H; OWN *op; do { fseek(deckf, dp->offsets[dp->last_card], SEEK_SET); dp->last_card = ++(dp->last_card) % dp->num_cards; type_maj = getc(deckf); } while (dp->gojf_used && type_maj == GOJF); type_min = getc(deckf); num = ntohl(getw(deckf)); printmes(); switch (type_maj) { case '+': /* get money */ if (type_min == 'A') { for (i = 0; i < num_play; i++) if (i != player) play[i].money -= num; num = num * (num_play - 1); } cur_p->money += num; break; case '-': /* lose money */ if (type_min == 'A') { for (i = 0; i < num_play; i++) if (i != player) play[i].money += num; num = num * (num_play - 1); } cur_p->money -= num; break; case 'M': /* move somewhere */ switch (type_min) { case 'F': /* move forward */ num -= cur_p->loc; if (num < 0) num += 40; break; case 'J': /* move to jail */ goto_jail(); return; case 'R': /* move to railroad */ spec = TRUE; num = (int)((cur_p->loc + 5)/10)*10 + 5 - cur_p->loc; break; case 'U': /* move to utility */ spec = TRUE; if (cur_p->loc >= 12 && cur_p->loc < 28) num = 28 - cur_p->loc; else { num = 12 - cur_p->loc; if (num < 0) num += 40; } break; case 'B': num = -num; break; } move(num); break; case 'T': /* tax */ if (dp == &CC_D) { per_h = 40; per_H = 115; } else { per_h = 25; per_H = 100; } num_h = num_H = 0; for (op = cur_p->own_list; op; op = op->next) if (op->sqr->type == PRPTY) { if (op->sqr->desc->houses == 5) ++num_H; else num_h += op->sqr->desc->houses; } num = per_h * num_h + per_H * num_H; printf( "You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num); if (num == 0) lucky(""); else cur_p->money -= num; break; case GOJF: /* get-out-of-jail-free card */ cur_p->num_gojf++; dp->gojf_used = TRUE; break; } spec = FALSE; } /* * This routine prints out the message on the card */ static void printmes() { char c; printline(); fflush(stdout); while ((c = getc(deckf)) != '\0') putchar(c); printline(); fflush(stdout); } bsd-games-2.17/monop/spec.c0000664000175000017500000000554707767741711014261 0ustar jsm28jsm28/* $NetBSD: spec.c,v 1.7 2003/08/07 09:37:30 agc Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)spec.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: spec.c,v 1.7 2003/08/07 09:37:30 agc Exp $"); #endif #endif /* not lint */ #include "monop.ext" static const char *const perc[] = { "10%", "ten percent", "%", "$200", "200", 0 }; void inc_tax() { /* collect income tax */ int worth, com_num; com_num = getinp("Do you wish to lose 10%% of your total worth or " "$200? ", perc); worth = cur_p->money + prop_worth(cur_p); printf("You were worth $%d", worth); worth /= 10; if (com_num > 2) { if (worth < 200) printf(". Good try, but not quite.\n"); else if (worth > 200) lucky(".\nGood guess. "); cur_p->money -= 200; } else { printf(", so you pay $%d", worth); if (worth > 200) printf(" OUCH!!!!.\n"); else if (worth < 200) lucky("\nGood guess. "); cur_p->money -= worth; } if (worth == 200) lucky("\nIt makes no difference! "); } void goto_jail() { /* move player to jail */ cur_p->loc = JAIL; } void lux_tax() { /* landing on luxury tax */ printf("You lose $75\n"); cur_p->money -= 75; } void cc() { /* draw community chest card */ get_card(&CC_D); } void chance() { /* draw chance card */ get_card(&CH_D); } bsd-games-2.17/monop/misc.c0000664000175000017500000001460410155330535014233 0ustar jsm28jsm28/* $NetBSD: misc.c,v 1.13 2004/11/05 21:30:32 dsl Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: misc.c,v 1.13 2004/11/05 21:30:32 dsl Exp $"); #endif #endif /* not lint */ #include "monop.ext" #include #include /* * This routine executes a truncated set of commands until a * "yes or "no" answer is gotten. */ int getyn(prompt) const char *prompt; { int com; for (;;) if ((com=getinp(prompt, yncoms)) < 2) return com; else (*func[com-2])(); } /* * This routine tells the player if he's out of money. */ void notify() { if (cur_p->money < 0) printf("That leaves you $%d in debt\n", -cur_p->money); else if (cur_p->money == 0) printf("that leaves you broke\n"); else if (fixing && !told_em && cur_p->money > 0) { printf("-- You are now Solvent ---\n"); told_em = TRUE; } } /* * This routine switches to the next player */ void next_play() { player = (player + 1) % num_play; cur_p = &play[player]; num_doub = 0; } /* * This routine gets an integer from the keyboard after the * given prompt. */ int get_int(prompt) const char *prompt; { int num; char *sp; int c; char buf[257]; for (;;) { inter: printf(prompt); num = 0; for (sp = buf; (c=getchar()) != '\n'; *sp++ = c) if (c == -1) /* check for interrupted system call */ goto inter; *sp = c; if (sp == buf) continue; for (sp = buf; isspace((unsigned char)*sp); sp++) continue; for (; isdigit((unsigned char)*sp); sp++) num = num * 10 + *sp - '0'; if (*sp == '\n') return num; else printf("I can't understand that\n"); } } /* * This routine sets the monopoly flag from the list given. */ void set_ownlist(pl) int pl; { int num; /* general counter */ MON *orig; /* remember starting monop ptr */ OWN *op; /* current owned prop */ OWN *orig_op; /* origianl prop before loop */ op = play[pl].own_list; #ifdef DEBUG printf("op [%d] = play[pl [%d] ].own_list;\n", op, pl); #endif while (op) { #ifdef DEBUG printf("op->sqr->type = %d\n", op->sqr->type); #endif switch (op->sqr->type) { case UTIL: #ifdef DEBUG printf(" case UTIL:\n"); #endif for (num = 0; op && op->sqr->type == UTIL; op = op->next) num++; play[pl].num_util = num; #ifdef DEBUG printf("play[pl].num_util = num [%d];\n", num); #endif break; case RR: #ifdef DEBUG printf(" case RR:\n"); #endif for (num = 0; op && op->sqr->type == RR; op = op->next) { #ifdef DEBUG printf("iter: %d\n", num); printf("op = %d, op->sqr = %d, " "op->sqr->type = %d\n", op, op->sqr, op->sqr->type); #endif num++; } play[pl].num_rr = num; #ifdef DEBUG printf("play[pl].num_rr = num [%d];\n", num); #endif break; case PRPTY: #ifdef DEBUG printf(" case PRPTY:\n"); #endif orig = op->sqr->desc->mon_desc; orig_op = op; num = 0; while (op && op->sqr->desc->mon_desc == orig) { #ifdef DEBUG printf("iter: %d\n", num); #endif num++; #ifdef DEBUG printf("op = op->next "); #endif op = op->next; #ifdef DEBUG printf("[%d];\n", op); #endif } #ifdef DEBUG printf("num = %d\n"); #endif if (orig == 0) { printf("panic: bad monopoly descriptor: " "orig = %p\n", orig); printf("player # %d\n", pl+1); printhold(pl); printf("orig_op = %p\n", orig_op); printf("orig_op->sqr->type = %d (PRPTY)\n", op->sqr->type); printf("orig_op->next = %p\n", op->next); printf("orig_op->sqr->desc = %p\n", op->sqr->desc); printf("op = %p\n", op); printf("op->sqr->type = %d (PRPTY)\n", op->sqr->type); printf("op->next = %p\n", op->next); printf("op->sqr->desc = %p\n", op->sqr->desc); printf("num = %d\n", num); } #ifdef DEBUG printf("orig->num_in = %d\n", orig->num_in); #endif if (num == orig->num_in) is_monop(orig, pl); else is_not_monop(orig); break; } } } /* * This routine sets things up as if it is a new monopoly */ void is_monop(mp, pl) MON *mp; int pl; { int i; mp->owner = pl; mp->num_own = mp->num_in; for (i = 0; i < mp->num_in; i++) mp->sq[i]->desc->monop = TRUE; mp->name = mp->mon_n; } /* * This routine sets things up as if it is no longer a monopoly */ void is_not_monop(mp) MON *mp; { int i; mp->owner = -1; for (i = 0; i < mp->num_in; i++) mp->sq[i]->desc->monop = FALSE; mp->name = mp->not_m; } /* * This routine gives a list of the current player's routine */ void list() { printhold(player); } /* * This routine gives a list of a given players holdings */ void list_all() { int pl; while ((pl = getinp("Whose holdings do you want to see? ", name_list)) < num_play) printhold(pl); } /* * This routine gives the players a chance before it exits. */ void quit() { putchar('\n'); if (getyn("Do you all really want to quit? ") == 0) exit(0); } bsd-games-2.17/monop/Makefrag0000664000175000017500000000362406773402557014613 0ustar jsm28jsm28# Makefrag - makefile fragment for monop # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. monop_CLEANFILES := cards.pck monop_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(MONOP_CARDSFILE)) monop_all: monop/monop monop/cards.pck monop/monop.6 monop/cards.pck: monop/initdeck monop/cards.inp $< monop/cards.inp $@ monop_install: monop_all $(INSTALL_BINARY) monop/monop $(INSTALL_PREFIX)$(GAMESDIR)/monop $(HIDE_GAME) monop $(INSTALL_MANUAL) monop/monop.6 $(INSTALL_DATA) monop/cards.pck $(INSTALL_PREFIX)$(MONOP_CARDSFILE) bsd-games-2.17/monop/print.c0000664000175000017500000001124510005547567014443 0ustar jsm28jsm28/* $NetBSD: print.c,v 1.8 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: print.c,v 1.8 2004/01/27 20:30:30 jsm Exp $"); #endif #endif /* not lint */ #include "monop.ext" static const char *header = "Name Own Price Mg # Rent"; static void printmorg(const SQUARE *); /* * This routine prints out the current board */ void printboard() { int i; printf("%s\t%s\n", header, header); for (i = 0; i < N_SQRS/2; i++) { printsq(i, FALSE); putchar('\t'); printsq(i+N_SQRS/2, TRUE); } } /* * This routine lists where each player is. */ void where() { int i; printf("%s Player\n", header); for (i = 0; i < num_play; i++) { printsq(play[i].loc, FALSE); printf(" %s (%d)", play[i].name, i+1); if (cur_p == &play[i]) printf(" *"); putchar('\n'); } } /* * This routine prints out an individual square */ void printsq(sqn, eoln) int sqn; bool eoln; { int rnt; PROP *pp; SQUARE *sqp; sqp = &board[sqn]; printf("%-10.10s", sqp->name); switch (sqp->type) { case SAFE: case CC: case CHANCE: case INC_TAX: case GOTO_J: case LUX_TAX: case IN_JAIL: if (!eoln) printf(" "); break; case PRPTY: pp = sqp->desc; if (sqp->owner < 0) { printf(" - %-8.8s %3d", pp->mon_desc->name, sqp->cost); if (!eoln) printf(" "); break; } printf(" %d %-8.8s %3d", sqp->owner+1, pp->mon_desc->name, sqp->cost); printmorg(sqp); if (pp->monop) { if (pp->houses < 5) if (pp->houses > 0) printf("%d %4d", pp->houses, pp->rent[pp->houses]); else printf("0 %4d", pp->rent[0] * 2); else printf("H %4d", pp->rent[5]); } else printf(" %4d", pp->rent[0]); break; case UTIL: if (sqp->owner < 0) { printf(" - 150"); if (!eoln) printf(" "); break; } printf(" %d 150", sqp->owner+1); printmorg(sqp); printf("%d", play[sqp->owner].num_util); if (!eoln) printf(" "); break; case RR: if (sqp->owner < 0) { printf(" - Railroad 200"); if (!eoln) printf(" "); break; } printf(" %d Railroad 200", sqp->owner+1); printmorg(sqp); rnt = 25; rnt <<= play[sqp->owner].num_rr - 1; printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1)); break; } if (eoln) putchar('\n'); } /* * This routine prints out the mortgage flag. */ static void printmorg(sqp) const SQUARE *sqp; { if (sqp->desc->morg) printf(" * "); else printf(" "); } /* * This routine lists the holdings of the player given */ void printhold(pl) int pl; { OWN *op; PLAY *pp; pp = &play[pl]; printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl + 1, pp->money + prop_worth(pp)); printf("\t$%d", pp->money); if (pp->num_gojf) { printf(", %d get-out-of-jail-free card", pp->num_gojf); if (pp->num_gojf > 1) putchar('s'); } putchar('\n'); if (pp->own_list) { printf("\t%s\n", header); for (op = pp->own_list; op; op = op->next) { putchar('\t'); printsq(sqnum(op->sqr), TRUE); } } } bsd-games-2.17/monop/brd.dat0000664000175000017500000000700007767741711014406 0ustar jsm28jsm28/* $NetBSD: brd.dat,v 1.3 2003/08/07 09:37:27 agc Exp $ */ /*- * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)brd.dat 5.5 (Berkeley) 5/31/93 */ /* name (COLOR) owner type desc cost */ {"=== GO ===", -1, SAFE, 0 }, {"Mediterranean ave. (P)", -1, PRPTY, &prop[0], 60 }, {"Community Chest i", -1, CC, }, {"Baltic ave. (P)", -1, PRPTY, &prop[1], 60 }, {"Income Tax", -1, INC_TAX, }, {"Reading RR", -1, RR, &rr[0], 200 }, {"Oriental ave. (L)", -1, PRPTY, &prop[2], 100 }, {"Chance i", -1, CHANCE, }, {"Vermont ave. (L)", -1, PRPTY, &prop[3], 100 }, {"Connecticut ave. (L)", -1, PRPTY, &prop[4], 120 }, {"Just Visiting", -1, SAFE, 0 }, {"St. Charles pl. (V)", -1, PRPTY, &prop[5], 140 }, {"Electric Co.", -1, UTIL, &util[0], 150 }, {"States ave. (V)", -1, PRPTY, &prop[6], 140 }, {"Virginia ave. (V)", -1, PRPTY, &prop[7], 160 }, {"Pennsylvania RR", -1, RR, &rr[1], 200 }, {"St. James pl. (O)", -1, PRPTY, &prop[8], 180 }, {"Community Chest ii", -1, CC, }, {"Tennessee ave. (O)", -1, PRPTY, &prop[9], 180 }, {"New York ave. (O)", -1, PRPTY, &prop[10], 200 }, {"Free Parking", -1, SAFE, 0 }, {"Kentucky ave. (R)", -1, PRPTY, &prop[11], 220 }, {"Chance ii", -1, CHANCE, }, {"Indiana ave. (R)", -1, PRPTY, &prop[12], 220 }, {"Illinois ave. (R)", -1, PRPTY, &prop[13], 240 }, {"B&O RR", -1, RR, &rr[2], 200 }, {"Atlantic ave. (Y)", -1, PRPTY, &prop[14], 260 }, {"Ventnor ave. (Y)", -1, PRPTY, &prop[15], 260 }, {"Water Works", -1, UTIL, &util[1], 150 }, {"Marvin Gardens (Y)", -1, PRPTY, &prop[16], 280 }, {"GO TO JAIL", -1, GOTO_J, }, {"Pacific ave. (G)", -1, PRPTY, &prop[17], 300 }, {"N. Carolina ave. (G)", -1, PRPTY, &prop[18], 300 }, {"Community Chest iii", -1, CC, }, {"Pennsylvania ave. (G)", -1, PRPTY, &prop[19], 320 }, {"Short Line RR", -1, RR, &rr[3], 200 }, {"Chance iii", -1, CHANCE, }, {"Park place (D)", -1, PRPTY, &prop[20], 350 }, {"Luxury Tax", -1, LUX_TAX, }, {"Boardwalk (D)", -1, PRPTY, &prop[21], 400 }, {"JAIL", -1, IN_JAIL, } bsd-games-2.17/monop/monop.h0000664000175000017500000001361010005547567014442 0ustar jsm28jsm28/* $NetBSD: monop.h,v 1.12 2004/01/27 20:30:30 jsm Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)monop.h 8.1 (Berkeley) 5/31/93 */ #include #include #include #include #define bool char #define TRUE (1) #define FALSE (0) #define N_MON 8 /* number of monopolies */ #define N_PROP 22 /* number of normal property squares */ #define N_RR 4 /* number of railroads */ #define N_UTIL 2 /* number of utilities */ #define N_SQRS 40 /* number of squares on board */ #define MAX_PL 9 /* maximum number of players */ #define MAX_PRP (N_PROP+N_RR+N_UTIL) /* max # ownable property */ /* square type numbers */ #define PRPTY 0 /* normal property */ #define RR 1 /* railroad */ #define UTIL 2 /* water works - electric co */ #define SAFE 3 /* safe spot */ #define CC 4 /* community chest */ #define CHANCE 5 /* chance (surprise!!!) */ #define INC_TAX 6 /* Income tax */ #define GOTO_J 7 /* Go To Jail! */ #define LUX_TAX 8 /* Luxury tax */ #define IN_JAIL 9 /* In jail */ #define JAIL 40 /* JAIL square number */ #define lucky(str) printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1]) #define printline() printf("------------------------------\n") #define sqnum(sqp) (sqp - board) #define swap(A1,A2) if ((A1) != (A2)) { \ (A1) ^= (A2); \ (A2) ^= (A1); \ (A1) ^= (A2); \ } struct sqr_st { /* structure for square */ const char *name; /* place name */ short owner; /* owner number */ short type; /* place type */ struct prp_st *desc; /* description struct */ int cost; /* cost */ }; typedef struct sqr_st SQUARE; struct mon_st { /* monopoly description structure */ const char *name; /* monop. name (color) */ short owner; /* owner of monopoly */ short num_in; /* # in monopoly */ short num_own; /* # owned (-1: not poss. monop)*/ short h_cost; /* price of houses */ const char *not_m; /* name if not monopoly */ const char *mon_n; /* name if a monopoly */ unsigned char sqnums[3]; /* Square numbers (used to init)*/ SQUARE *sq[3]; /* list of squares in monop */ }; typedef struct mon_st MON; /* * This struct describes a property. For railroads and utilities, only * the "morg" member is used. */ struct prp_st { /* property description structure */ bool morg; /* set if mortgaged */ bool monop; /* set if monopoly */ short square; /* square description */ short houses; /* number of houses */ MON *mon_desc; /* name of color */ int rent[6]; /* rents */ }; struct own_st { /* element in list owned things */ SQUARE *sqr; /* pointer to square */ struct own_st *next; /* next in list */ }; typedef struct own_st OWN; struct plr_st { /* player description structure */ char *name; /* owner name */ short num_gojf; /* # of get-out-of-jail-free's */ short num_rr; /* # of railroads owned */ short num_util; /* # of water works/elec. co. */ short loc; /* location on board */ short in_jail; /* count of turns in jail */ int money; /* amount of money */ OWN *own_list; /* start of propery list */ }; typedef struct plr_st PLAY; typedef struct prp_st PROP; typedef struct prp_st RR_S; typedef struct prp_st UTIL_S; /* cards.c */ void init_decks(void); void get_card(DECK *); /* execute.c */ void execute(int); void do_move(void); void move(int); void save(void); void restore(void); int rest_f(const char *); /* getinp.c */ int getinp(const char *, const char *const []); /* houses.c */ void buy_houses(void); void sell_houses(void); /* jail.c */ void card(void); void ret_card(PLAY *); void pay(void); int move_jail(int, int ); void printturn(void); /* misc.c */ int getyn(const char *); void notify(void); void next_play(void); int get_int(const char *); void set_ownlist(int); void is_monop(MON *, int); void is_not_monop(MON *); void list(void); void list_all(void); void quit(void); /* morg.c */ void mortgage(void); void unmortgage(void); void force_morg(void); /* print.c */ void printboard(void); void where(void); void printsq(int, bool); void printhold(int); /* prop.c */ void buy(int, SQUARE *); void add_list(int, OWN **, int); void del_list(int, OWN **, short); void bid(void); int prop_worth(PLAY *); /* rent.c */ void rent(SQUARE *); /* roll.c */ int roll(int, int); /* spec.c */ void inc_tax(void); void goto_jail(void); void lux_tax(void); void cc(void); void chance(void); /* trade.c */ void trade(void); void resign(void); bsd-games-2.17/arithmetic/0000775000175000017500000000000010205246607014132 5ustar jsm28jsm28bsd-games-2.17/arithmetic/Makefile.bsd0000664000175000017500000000025406350047433016344 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.4 1995/03/21 11:59:28 cgd Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= arithmetic MAN= arithmetic.6 HIDEGAME=hidegame .include bsd-games-2.17/arithmetic/arithmetic.c0000664000175000017500000002640010155330535016427 0ustar jsm28jsm28/* $NetBSD: arithmetic.c,v 1.21 2004/11/05 21:30:31 dsl Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Eamonn McManus of Trinity College Dublin. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: arithmetic.c,v 1.21 2004/11/05 21:30:31 dsl Exp $"); #endif #endif /* not lint */ /* * By Eamonn McManus, Trinity College Dublin . * * The operation of this program mimics that of the standard Unix game * `arithmetic'. I've made it as close as I could manage without examining * the source code. The principal differences are: * * The method of biasing towards numbers that had wrong answers in the past * is different; original `arithmetic' seems to retain the bias forever, * whereas this program lets the bias gradually decay as it is used. * * Original `arithmetic' delays for some period (3 seconds?) after printing * the score. I saw no reason for this delay, so I scrapped it. * * There is no longer a limitation on the maximum range that can be supplied * to the program. The original program required it to be less than 100. * Anomalous results may occur with this program if ranges big enough to * allow overflow are given. * * I have obviously not attempted to duplicate bugs in the original. It * would go into an infinite loop if invoked as `arithmetic / 0'. It also * did not recognise an EOF in its input, and would continue trying to read * after it. It did not check that the input was a valid number, treating any * garbage as 0. Finally, it did not flush stdout after printing its prompt, * so in the unlikely event that stdout was not a terminal, it would not work * properly. */ #include #include #include #include #include #include #include #include #include int getrandom(int, int, int); void intr(int) __attribute__((__noreturn__)); int main(int, char *[]); int opnum(int); void penalise(int, int, int); int problem(void); void showstats(int); void usage(void) __attribute__((__noreturn__)); const char keylist[] = "+-x/"; const char defaultkeys[] = "+-"; const char *keys = defaultkeys; int nkeys = sizeof(defaultkeys) - 1; int rangemax = 10; int nright, nwrong; time_t qtime; #define NQUESTS 20 /* * Select keys from +-x/ to be asked addition, subtraction, multiplication, * and division problems. More than one key may be given. The default is * +-. Specify a range to confine the operands to 0 - range. Default upper * bound is 10. After every NQUESTS questions, statistics on the performance * so far are printed. */ int main(argc, argv) int argc; char **argv; { int ch, cnt; /* Revoke setgid privileges */ setregid(getgid(), getgid()); while ((ch = getopt(argc, argv, "r:o:")) != -1) switch(ch) { case 'o': { const char *p; for (p = keys = optarg; *p; ++p) if (!strchr(keylist, *p)) errx(1, "arithmetic: unknown key."); nkeys = p - optarg; break; } case 'r': if ((rangemax = atoi(optarg)) <= 0) errx(1, "arithmetic: invalid range."); break; case '?': default: usage(); } if (argc -= optind) usage(); /* Seed the random-number generator. */ srandom((int)time((time_t *)NULL)); (void)signal(SIGINT, intr); /* Now ask the questions. */ for (;;) { for (cnt = NQUESTS; cnt--;) if (problem() == EOF) exit(0); showstats(0); } /* NOTREACHED */ } /* Handle interrupt character. Print score and exit. */ void intr(dummy) int dummy __attribute__((__unused__)); { showstats(1); exit(0); } /* Print score. Original `arithmetic' had a delay after printing it. */ void showstats(bool_sigint) int bool_sigint; { if (nright + nwrong > 0) { (void)printf("\n\nRights %d; Wrongs %d; Score %d%%", nright, nwrong, (int)(100L * nright / (nright + nwrong))); if (nright > 0) (void)printf("\nTotal time %ld seconds; %.1f seconds per problem\n\n", (long)qtime, (float)qtime / nright); } if(!bool_sigint) { (void)printf("Press RETURN to continue...\n"); while(!getchar()) ; } (void)printf("\n"); } /* * Pick a problem and ask it. Keeps asking the same problem until supplied * with the correct answer, or until EOF or interrupt is typed. Problems are * selected such that the right operand and either the left operand (for +, x) * or the correct result (for -, /) are in the range 0 to rangemax. Each wrong * answer causes the numbers in the problem to be penalised, so that they are * more likely to appear in subsequent problems. */ int problem() { char *p; time_t start, finish; int left, op, right, result; char line[80]; right = left = result = 0; op = keys[random() % nkeys]; if (op != '/') right = getrandom(rangemax + 1, op, 1); retry: /* Get the operands. */ switch (op) { case '+': left = getrandom(rangemax + 1, op, 0); result = left + right; break; case '-': result = getrandom(rangemax + 1, op, 0); left = right + result; break; case 'x': left = getrandom(rangemax + 1, op, 0); result = left * right; break; case '/': right = getrandom(rangemax, op, 1) + 1; result = getrandom(rangemax + 1, op, 0); left = right * result + random() % right; break; } /* * A very big maxrange could cause negative values to pop * up, owing to overflow. */ if (result < 0 || left < 0) goto retry; (void)printf("%d %c %d = ", left, op, right); (void)fflush(stdout); (void)time(&start); /* * Keep looping until the correct answer is given, or until EOF or * interrupt is typed. */ for (;;) { if (!fgets(line, sizeof(line), stdin)) { (void)printf("\n"); return(EOF); } for (p = line; *p && isspace((unsigned char)*p); ++p); if (!isdigit((unsigned char)*p)) { (void)printf("Please type a number.\n"); continue; } if (atoi(p) == result) { (void)printf("Right!\n"); ++nright; break; } /* Wrong answer; penalise and ask again. */ (void)printf("What?\n"); ++nwrong; penalise(right, op, 1); if (op == 'x' || op == '+') penalise(left, op, 0); else penalise(result, op, 0); } /* * Accumulate the time taken. Obviously rounding errors happen here; * however they should cancel out, because some of the time you are * charged for a partially elapsed second at the start, and some of * the time you are not charged for a partially elapsed second at the * end. */ (void)time(&finish); qtime += finish - start; return(0); } /* * Here is the code for accumulating penalties against the numbers for which * a wrong answer was given. The right operand and either the left operand * (for +, x) or the result (for -, /) are stored in a list for the particular * operation, and each becomes more likely to appear again in that operation. * Initially, each number is charged a penalty of WRONGPENALTY, giving it that * many extra chances of appearing. Each time it is selected because of this, * its penalty is decreased by one; it is removed when it reaches 0. * * The penalty[] array gives the sum of all penalties in the list for * each operation and each operand. The penlist[] array has the lists of * penalties themselves. */ int penalty[sizeof(keylist) - 1][2]; struct penalty { int value, penalty; /* Penalised value and its penalty. */ struct penalty *next; } *penlist[sizeof(keylist) - 1][2]; #define WRONGPENALTY 5 /* Perhaps this should depend on maxrange. */ /* * Add a penalty for the number `value' to the list for operation `op', * operand number `operand' (0 or 1). If we run out of memory, we just * forget about the penalty (how likely is this, anyway?). */ void penalise(value, op, operand) int value, op, operand; { struct penalty *p; op = opnum(op); if ((p = (struct penalty *)malloc((u_int)sizeof(*p))) == NULL) return; p->next = penlist[op][operand]; penlist[op][operand] = p; penalty[op][operand] += p->penalty = WRONGPENALTY; p->value = value; } /* * Select a random value from 0 to maxval - 1 for operand `operand' (0 or 1) * of operation `op'. The random number we generate is either used directly * as a value, or represents a position in the penalty list. If the latter, * we find the corresponding value and return that, decreasing its penalty. */ int getrandom(maxval, op, operand) int maxval, op, operand; { int value; struct penalty **pp, *p; op = opnum(op); value = random() % (maxval + penalty[op][operand]); /* * 0 to maxval - 1 is a number to be used directly; bigger values * are positions to be located in the penalty list. */ if (value < maxval) return(value); value -= maxval; /* * Find the penalty at position `value'; decrement its penalty and * delete it if it reaches 0; return the corresponding value. */ for (pp = &penlist[op][operand]; (p = *pp) != NULL; pp = &p->next) { if (p->penalty > value) { value = p->value; penalty[op][operand]--; if (--(p->penalty) <= 0) { p = p->next; (void)free((char *)*pp); *pp = p; } return(value); } value -= p->penalty; } /* * We can only get here if the value from the penalty[] array doesn't * correspond to the actual sum of penalties in the list. Provide an * obscure message. */ errx(1, "arithmetic: bug: inconsistent penalties."); /* NOTREACHED */ } /* Return an index for the character op, which is one of [+-x/]. */ int opnum(op) int op; { char *p; if (op == 0 || (p = strchr(keylist, op)) == NULL) errx(1, "arithmetic: bug: op %c not in keylist %s", op, keylist); return(p - keylist); } /* Print usage message and quit. */ void usage() { (void)fprintf(stderr, "Usage: %s [-o +-x/] [-r range]\n", getprogname()); exit(1); } bsd-games-2.17/arithmetic/Makefrag0000664000175000017500000000346410005555405015576 0ustar jsm28jsm28# Makefrag - makefile fragment for arithmetic # # Copyright (c) 1997, 1998, 2004 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. arithmetic_DEFS := $(GETPROGNAME_DEFS) arithmetic_DIRS := $(GAMESDIR) $(MAN6DIR) arithmetic_all: arithmetic/arithmetic arithmetic/arithmetic.6 arithmetic_install: arithmetic/arithmetic $(INSTALL_BINARY) arithmetic/arithmetic $(INSTALL_PREFIX)$(GAMESDIR)/arithmetic $(HIDE_GAME) arithmetic $(INSTALL_MANUAL) arithmetic/arithmetic.6 bsd-games-2.17/arithmetic/arithmetic.60000664000175000017500000000703707767741711016400 0ustar jsm28jsm28.\" $NetBSD: arithmetic.6,v 1.11 2003/08/07 09:36:52 agc Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Eamonn McManus of Trinity College Dublin. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)arithmetic.6 8.1 (Berkeley) 5/31/93 .\" .Dd May 31, 1993 .Dt ARITHMETIC 6 .Os .Sh NAME .Nm arithmetic .Nd quiz on simple arithmetic .Sh SYNOPSIS .Nm .Op Fl o Ar +\-x/ .Op Fl r Ar range .Sh DESCRIPTION .Nm asks you to solve problems in simple arithmetic. Each question must be answered correctly before going on to the next. After every 20 problems, it prints the score so far and the time taken. You can quit at any time by typing the interrupt or end-of-file character. .Pp The options are as follows: .Bl -tag -width indent .It Fl o By default, .Nm asks questions on addition of numbers from 0 to 10, and corresponding subtraction. By supplying one or more of the characters .Ar +\-x/ , you can ask for problems in addition, subtraction, multiplication, and division, respectively. If you give one of these characters more than once, that kind of problem will be asked correspondingly more often. .It Fl r If a .Ar range is supplied, .Nm selects the numbers in its problems in the following way. For addition and multiplication, the numbers to be added or multiplied are between 0 and .Ar range , inclusive. For subtraction and division, both the required result and the number to divide by or subtract will be between 0 and .Ar range . (Of course, .Nm will not ask you to divide by 0.) The default .I range is 10. .El .Pp When you get a problem wrong, .Nm will remember the numbers involved, and will tend to select those numbers more often than others, in problems of the same sort. Eventually it will forgive and forget. .Pp .Nm cannot be persuaded to tell you the right answer. You must work it out for yourself. .Sh DIAGNOSTICS .Dq What? if you get a question wrong. .Dq Right! if you get it right. .Dq Please type a number. if .Nm doesn't understand what you typed. .Sh SEE ALSO .Xr bc 1 , .Xr dc 1 bsd-games-2.17/countmail/0000775000175000017500000000000010205246607013774 5ustar jsm28jsm28bsd-games-2.17/countmail/countmail.60000664000175000017500000000417210011302370016043 0ustar jsm28jsm28.\" $NetBSD: countmail.6,v 1.10 2004/02/08 00:31:16 jsm Exp $ .\" .\" Copyright (c) 1997 Matthew R. Green .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd October 3, 1997 .Dt COUNTMAIL 6 .Os .Sh NAME .Nm countmail .Nd be obnoxious about how much mail you have .Sh SYNOPSIS .Nm .Sh DESCRIPTION The .Nm program counts your mail and tells you about it rather obnoxiously. .Sh HISTORY The .Nm program first appeared in .Nx 1.3 . .Nm was first written by .An Noah Friedman Aq friedman@splode.com in 1993. This version was written by Charles M. Hannum .Aq mycroft@NetBSD.org . .Sh CAVEATS The read loop is horrendously slow on every shell implementation tried. .Nm uses .Xr from 1 and .Xr wc 1 instead, though these are not shell builtins. .Sh SEE ALSO .Xr from 1 bsd-games-2.17/countmail/Makefile.bsd0000664000175000017500000000021706701650657016215 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.3 1999/02/13 23:53:57 lukem Exp $ SCRIPTS= countmail SCRIPTSDIR= /usr/games MAN= countmail.6 .include bsd-games-2.17/countmail/countmail0000664000175000017500000000732607641024615015725 0ustar jsm28jsm28#!/bin/sh # $NetBSD: countmail,v 1.5 2002/07/02 17:18:21 mycroft Exp $ # # Copyright (c) 1998, 2002 The NetBSD Foundation, Inc. # All rights reserved. # # This code is derived from software contributed to The NetBSD Foundation # by Charles M. Hannum. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by the NetBSD # Foundation, Inc. and its contributors. # 4. Neither the name of The NetBSD Foundation nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Count the messages in your mailbox, using only POSIX shell builtins. # # Caveats: # # The read loop is horrendously slow on every implementation I've # tried. I suggest using from(1) and wc(1) instead, though these are # not shell builtins. # for krb. #set -- `from -t` #v=$3 set -- `from | wc -l` v=$1 #v=`from | wc -l` #v=0 #exec 0&2 exit 1 ;; esac case $v in *10) y=TEN ;; *11) y=ELEVEN ;; *12) y=TWELVE ;; *13) y=THIRTEEN ;; *14) y=FOURTEEN ;; *15) y=FIFTEEN ;; *16) y=SIXTEEN ;; *17) y=SEVENTEEN ;; *18) y=EIGHTEEN ;; *19) y=NINETEEN ;; *2?) y=TWENTY ;; *3?) y=THIRTY ;; *4?) y=FORTY ;; *5?) y=FIFTY ;; *6?) y=SIXTY ;; *7?) y=SEVENTY ;; *8?) y=EIGHTY ;; *9?) y=NINETY ;; *) y= ;; esac case $v in *[01]? | *?0) ;; *) y=$y- ;; esac case $v in *1?) ;; *1) y=${y}ONE ;; *2) y=${y}TWO ;; *3) y=${y}THREE ;; *4) y=${y}FOUR ;; *5) y=${y}FIVE ;; *6) y=${y}SIX ;; *7) y=${y}SEVEN ;; *8) y=${y}EIGHT ;; *9) y=${y}NINE ;; esac case $v in *1??) z=ONE ;; *2??) z=TWO ;; *3??) z=THREE ;; *4??) z=FOUR ;; *5??) z=FIVE ;; *6??) z=SIX ;; *7??) z=SEVEN ;; *8??) z=EIGHT ;; *9??) z=NINE ;; *) z= ;; esac set $z ${z:+HUNDRED} $y $x $* ;; esac g=$(($g + 1)) v=${v%%???} done p=S case "$*" in "") set ZERO ;; ONE) p= ;; esac echo "$*! $* MAIL MESSAGE$p! HAHAHAHAHA!" bsd-games-2.17/countmail/Makefrag0000664000175000017500000000336106773402557015454 0ustar jsm28jsm28# Makefrag - makefile fragment for countmail # # Copyright (c) 1997, 1998 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. countmail_DIRS := $(GAMESDIR) $(MAN6DIR) countmail_all: countmail/countmail countmail/countmail.6 countmail_install: countmail_all $(INSTALL_SCRIPT) countmail/countmail $(INSTALL_PREFIX)$(GAMESDIR)/countmail $(HIDE_GAME) countmail $(INSTALL_MANUAL) countmail/countmail.6 bsd-games-2.17/battlestar/0000775000175000017500000000000010205246610014140 5ustar jsm28jsm28bsd-games-2.17/battlestar/command1.c0000664000175000017500000002004507767741711016031 0ustar jsm28jsm28/* $NetBSD: command1.c,v 1.2 2003/08/07 09:37:00 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)com1.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: command1.c,v 1.2 2003/08/07 09:37:00 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" int moveplayer(thataway, token) int thataway, token; { wordnumber++; if ((!notes[CANTMOVE] && !notes[LAUNCHED]) || testbit(location[position].objects, LAND) || (fuel > 0 && notes[LAUNCHED])) { if (thataway) { position = thataway; newway(token); ourtime++; } else { puts("You can't go this way."); newway(token); whichway(location[position]); return (0); } } else { if (notes[CANTMOVE] && !notes[LAUNCHED]) puts("You aren't able to move; you better drop something."); else puts("You are out of fuel; now you will rot in space forever!"); } return (1); } void convert(tothis) /* Converts day to night and vice versa. */ int tothis; /* Day objects are permanent. Night objects * are added */ { /* at dusk, and subtracted at dawn. */ const struct objs *p; unsigned int i, j; if (tothis == TONIGHT) { for (i = 1; i <= NUMOFROOMS; i++) for (j = 0; j < NUMOFWORDS; j++) nightfile[i].objects[j] = dayfile[i].objects[j]; for (p = nightobjs; p->room != 0; p++) setbit(nightfile[p->room].objects, p->obj); location = nightfile; } else { for (i = 1; i <= NUMOFROOMS; i++) for (j = 0; j < NUMOFWORDS; j++) dayfile[i].objects[j] = nightfile[i].objects[j]; for (p = nightobjs; p->room != 0; p++) clearbit(dayfile[p->room].objects, p->obj); location = dayfile; } } void news() { int n; int hurt; if (ourtime > 30 && position < 32) { puts("An explosion of shuddering magnitude splinters bulkheads and"); puts("ruptures the battlestar's hull. You are sucked out into the"); puts("frozen void of space and killed."); die(); } if (ourtime > 20 && position < 32) puts("Explosions rock the battlestar."); if (ourtime > snooze) { puts("You drop from exhaustion..."); zzz(); } if (ourtime > snooze - 5) puts("You're getting tired."); if (ourtime > (rythmn + CYCLE)) { if (location == nightfile) { convert(TODAY); if (OUTSIDE && ourtime - rythmn - CYCLE < 10) { puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn."); puts("You awake from a misty dream-world into stark reality."); puts("It is day."); } } else { convert(TONIGHT); clearbit(location[POOLS].objects, BATHGOD); if (OUTSIDE && ourtime - rythmn - CYCLE < 10) { puts("The dying sun sinks into the ocean, leaving a blood-stained sunset."); puts("The sky slowly fades from orange to violet to black. A few stars"); puts("flicker on, and it is night."); puts("The world seems completely different at night."); } } rythmn = ourtime - ourtime % CYCLE; } if (!wiz && !tempwiz) if ((testbit(inven, TALISMAN) || testbit(wear, TALISMAN)) && (testbit(inven, MEDALION) || testbit(wear, MEDALION)) && (testbit(inven, AMULET) || testbit(wear, AMULET))) { tempwiz = 1; puts("The three amulets glow and reenforce each other in power.\nYou are now a wizard."); } if (testbit(location[position].objects, ELF)) { printf("%s\n", objdes[ELF]); fight(ELF, rnd(30)); } if (testbit(location[position].objects, DARK)) { printf("%s\n", objdes[DARK]); fight(DARK, 100); } if (testbit(location[position].objects, WOODSMAN)) { printf("%s\n", objdes[WOODSMAN]); fight(WOODSMAN, 50); } switch (position) { case 267: case 257: /* entering a cave */ case 274: case 246: notes[CANTSEE] = 1; break; case 160: case 216: /* leaving a cave */ case 230: case 231: case 232: notes[CANTSEE] = 0; break; } if (testbit(location[position].objects, GIRL)) meetgirl = 1; if (meetgirl && CYCLE * 1.5 - ourtime < 10) { setbit(location[GARDEN].objects, GIRLTALK); setbit(location[GARDEN].objects, LAMPON); setbit(location[GARDEN].objects, ROPE); } if (position == DOCK && (beenthere[position] || ourtime > CYCLE)) { clearbit(location[DOCK].objects, GIRL); clearbit(location[DOCK].objects, MAN); } if (meetgirl && ourtime - CYCLE * 1.5 > 10) { clearbit(location[GARDEN].objects, GIRLTALK); clearbit(location[GARDEN].objects, LAMPON); clearbit(location[GARDEN].objects, ROPE); meetgirl = 0; } if (testbit(location[position].objects, CYLON)) { puts("Oh my God, you're being shot at by an alien spacecraft!"); printf("The targeting computer says we have %d seconds to attack!\n", ourclock); fflush(stdout); sleep(1); if (!visual()) { hurt = rnd(NUMOFINJURIES); injuries[hurt] = 1; puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll."); puts("The viper shudders under a terrible explosion."); printf("I'm afraid you have suffered %s.\n", ouch[hurt]); } else clearbit(location[position].objects, CYLON); } if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]) { puts("I'm afraid you have suffered fatal injuries."); die(); } for (n = 0; n < NUMOFINJURIES; n++) if (injuries[n] == 1) { injuries[n] = 2; if (WEIGHT > 5) WEIGHT -= 5; else WEIGHT = 0; } if (injuries[ARM] == 2) { if (CUMBER > 5) CUMBER -= 5; else CUMBER = 0; injuries[ARM]++; } if (injuries[RIBS] == 2) { if (CUMBER > 2) CUMBER -= 2; else CUMBER = 0; injuries[RIBS]++; } if (injuries[SPINE] == 2) { WEIGHT = 0; injuries[SPINE]++; } if (carrying > WEIGHT || encumber > CUMBER) notes[CANTMOVE] = 1; else notes[CANTMOVE] = 0; } void crash() { int hurt1, hurt2; fuel--; if (!location[position].flyhere || (testbit(location[position].objects, LAND) && fuel <= 0)) { if (!location[position].flyhere) puts("You're flying too low. We're going to crash!"); else { puts("You're out of fuel. We'll have to crash land!"); if (!location[position].down) { puts("Your viper strikes the ground and explodes into fiery fragments."); puts("Thick black smoke billows up from the wreckage."); die(); } position = location[position].down; } notes[LAUNCHED] = 0; setbit(location[position].objects, CRASH); ourtime += rnd(CYCLE / 4); puts("The viper explodes into the ground and you lose consciousness..."); zzz(); hurt1 = rnd(NUMOFINJURIES - 2) + 2; hurt2 = rnd(NUMOFINJURIES - 2) + 2; injuries[hurt1] = 1; injuries[hurt2] = 1; injuries[0] = 1;/* abrasions */ injuries[1] = 1;/* lacerations */ printf("I'm afraid you have suffered %s and %s.\n", ouch[hurt1], ouch[hurt2]); } } bsd-games-2.17/battlestar/words.c0000664000175000017500000001716107767741711015475 0ustar jsm28jsm28/* $NetBSD: words.c,v 1.11 2003/08/07 09:37:03 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)words.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: words.c,v 1.11 2003/08/07 09:37:03 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" struct wlist wlist[] = { { "knife", KNIFE, OBJECT, NULL }, { "sword", SWORD, NOUNS, NULL }, { "scabbard", SWORD, OBJECT, NULL }, { "fine", SWORD, OBJECT, NULL }, { "two-handed", TWO_HANDED, OBJECT, NULL }, { "cleaver", CLEAVER, OBJECT, NULL }, { "broadsword", BROAD, OBJECT, NULL }, { "mail", MAIL, OBJECT, NULL }, { "coat", MAIL, OBJECT, NULL }, { "helmet", HELM, OBJECT, NULL }, { "shield", SHIELD, OBJECT, NULL }, { "maid", MAID, OBJECT, NULL }, { "maid's", MAID, OBJECT, NULL }, { "body", BODY, NOUNS, NULL }, { "viper", VIPER, OBJECT, NULL }, { "lamp", LAMPON, OBJECT, NULL }, { "lantern", LAMPON, OBJECT, NULL }, { "shoes", SHOES, OBJECT, NULL }, { "pajamas", PAJAMAS, OBJECT, NULL }, { "robe", ROBE, OBJECT, NULL }, { "amulet", AMULET, NOUNS, NULL }, { "medallion", MEDALION, NOUNS, NULL }, { "talisman", TALISMAN, NOUNS, NULL }, { "woodsman", DEADWOOD, OBJECT, NULL }, { "woodsman's", DEADWOOD, OBJECT, NULL }, { "mallet", MALLET, OBJECT, NULL }, { "laser", LASER, OBJECT, NULL }, { "pistol", LASER, OBJECT, NULL }, { "blaster", LASER, OBJECT, NULL }, { "gun", LASER, OBJECT, NULL }, { "goddess", NORMGOD, NOUNS, NULL }, { "grenade", GRENADE, OBJECT, NULL }, { "chain", CHAIN, OBJECT, NULL }, { "rope", ROPE, OBJECT, NULL }, { "levis", LEVIS, OBJECT, NULL }, { "pants", LEVIS, OBJECT, NULL }, { "mace", MACE, OBJECT, NULL }, { "shovel", SHOVEL, OBJECT, NULL }, { "halberd", HALBERD, OBJECT, NULL }, { "compass", COMPASS, OBJECT, NULL }, { "elf", ELF, OBJECT, NULL }, { "coins", COINS, OBJECT, NULL }, { "matches", MATCHES, OBJECT, NULL }, { "match", MATCHES, OBJECT, NULL }, { "book", MATCHES, OBJECT, NULL }, { "man", MAN, NOUNS, NULL }, { "papaya", PAPAYAS, OBJECT, NULL }, { "papayas", PAPAYAS, OBJECT, NULL }, { "pineapple", PINEAPPLE, OBJECT, NULL }, { "kiwi", KIWI, OBJECT, NULL }, { "coconut", COCONUTS, OBJECT, NULL }, { "coconuts", COCONUTS, OBJECT, NULL }, { "mango", MANGO, OBJECT, NULL }, { "ring", RING, OBJECT, NULL }, { "potion", POTION, OBJECT, NULL }, { "bracelet", BRACELET, OBJECT, NULL }, { "timer", TIMER, NOUNS, NULL }, { "bomb", BOMB, OBJECT, NULL }, { "warhead", BOMB, OBJECT, NULL }, { "girl", NATIVE, NOUNS, NULL }, { "native", NATIVE, NOUNS, NULL }, { "horse", HORSE, OBJECT, NULL }, { "stallion", HORSE, OBJECT, NULL }, { "car", CAR, OBJECT, NULL }, { "volare", CAR, OBJECT, NULL }, { "pot", POT, OBJECT, NULL }, { "jewels", POT, OBJECT, NULL }, { "bar", BAR, OBJECT, NULL }, { "diamond", BLOCK, OBJECT, NULL }, { "block", BLOCK, OBJECT, NULL }, { "up", UP, VERB, NULL }, { "u", UP, VERB, NULL }, { "down", DOWN, VERB, NULL }, { "d", DOWN, VERB, NULL }, { "ahead", AHEAD, VERB, NULL }, { "a", AHEAD, VERB, NULL }, { "back", BACK, VERB, NULL }, { "b", BACK, VERB, NULL }, { "right", RIGHT, VERB, NULL }, { "r", RIGHT, VERB, NULL }, { "left", LEFT, VERB, NULL }, { "l", LEFT, VERB, NULL }, { "take", TAKE, VERB, NULL }, { "get", TAKE, VERB, NULL }, { "use", USE, VERB, NULL }, { "look", LOOK, VERB, NULL }, { "lo", LOOK, VERB, NULL }, { "quit", QUIT, VERB, NULL }, { "q", QUIT, VERB, NULL }, { "su", SU, VERB, NULL }, { "drop", DROP, VERB, NULL }, { "draw", DRAW, VERB, NULL }, { "pull", DRAW, VERB, NULL }, { "carry", DRAW, VERB, NULL }, { "wear", WEARIT, VERB, NULL }, { "sheathe", WEARIT, VERB, NULL }, { "put", PUT, VERB, NULL }, { "buckle", PUT, VERB, NULL }, { "strap", PUT, VERB, NULL }, { "tie", PUT, VERB, NULL }, { "inven", INVEN, VERB, NULL }, { "i", INVEN, VERB, NULL }, { "everything", EVERYTHING, OBJECT, NULL }, { "all", EVERYTHING, OBJECT, NULL }, { "and", AND, CONJ, NULL }, { ",", AND, CONJ, NULL }, { "kill", KILL, VERB, NULL }, { "fight", KILL, VERB, NULL }, { "ravage", RAVAGE, VERB, NULL }, { "rape", RAVAGE, VERB, NULL }, { "undress", UNDRESS, VERB, NULL }, { "throw", THROW, VERB, NULL }, { "launch", LAUNCH, VERB, NULL }, { "land", LANDIT, VERB, NULL }, { "light", LIGHT, VERB, NULL }, { "strike", LIGHT, VERB, NULL }, { "follow", FOLLOW, VERB, NULL }, { "chase", FOLLOW, VERB, NULL }, { "kiss", KISS, VERB, NULL }, { "love", LOVE, VERB, NULL }, { "fuck", LOVE, VERB, NULL }, { "give", GIVE, VERB, NULL }, { "smite", SMITE, VERB, NULL }, { "attack", SMITE, VERB, NULL }, { "swing", SMITE, VERB, NULL }, { "stab", SMITE, VERB, NULL }, { "slice", SMITE, VERB, NULL }, { "cut", SMITE, VERB, NULL }, { "hack", SMITE, VERB, NULL }, { "shoot", SHOOT, VERB, NULL }, { "blast", SHOOT, VERB, NULL }, { "open", OPEN, VERB, NULL }, { "unlock", OPEN, VERB, NULL }, { "on", ON, PREPS, NULL }, { "off", OFF, PREPS, NULL }, { "time", TIME, VERB, NULL }, { "sleep", SLEEP, VERB, NULL }, { "dig", DIG, VERB, NULL }, { "eat", EAT, VERB, NULL }, { "swim", SWIM, VERB, NULL }, { "drink", DRINK, VERB, NULL }, { "door", DOOR, NOUNS, NULL }, { "verbose", VERBOSE, VERB, NULL }, { "brief", BRIEF, VERB, NULL }, { "save", SAVE, VERB, NULL }, { "ride", RIDE, VERB, NULL }, { "mount", RIDE, VERB, NULL }, { "drive", DRIVE, VERB, NULL }, { "start", DRIVE, VERB, NULL }, { "score", SCORE, VERB, NULL }, { "points", SCORE, VERB, NULL }, { "bury", BURY, VERB, NULL }, { "jump", JUMP, VERB, NULL }, { "kick", KICK, VERB, NULL }, { "kerosene", 0, ADJS, NULL }, { "plumed", 0, ADJS, NULL }, { "ancient", 0, ADJS, NULL }, { "golden", 0, ADJS, NULL }, { "gold", 0, ADJS, NULL }, { "ostrich", 0, ADJS, NULL }, { "rusty", 0, ADJS, NULL }, { "old", 0, ADJS, NULL }, { "dented", 0, ADJS, NULL }, { "blue", 0, ADJS, NULL }, { "purple", 0, ADJS, NULL }, { "kingly", 0, ADJS, NULL }, { "the", 0, ADJS, NULL }, { "climb", AUXVERB, VERB, NULL }, { "move", AUXVERB, VERB, NULL }, { "make", AUXVERB, VERB, NULL }, { "to", 0, ADJS, NULL }, { NULL, 0, 0, NULL } }; bsd-games-2.17/battlestar/save.c0000664000175000017500000001453407767741711015276 0ustar jsm28jsm28/* $NetBSD: save.c,v 1.11 2003/08/07 09:37:03 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)save.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: save.c,v 1.11 2003/08/07 09:37:03 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" void restore(filename) const char *filename; { int n; int tmp; FILE *fp; if (filename == NULL) exit(1); /* Error determining save file name. */ if ((fp = fopen(filename, "r")) == 0) { err(1, "fopen %s", filename); } fread(&WEIGHT, sizeof WEIGHT, 1, fp); fread(&CUMBER, sizeof CUMBER, 1, fp); fread(&ourclock, sizeof ourclock, 1, fp); fread(&tmp, sizeof tmp, 1, fp); location = tmp ? dayfile : nightfile; for (n = 1; n <= NUMOFROOMS; n++) { fread(location[n].link, sizeof location[n].link, 1, fp); fread(location[n].objects, sizeof location[n].objects, 1, fp); } fread(inven, sizeof inven, 1, fp); fread(wear, sizeof wear, 1, fp); fread(injuries, sizeof injuries, 1, fp); fread(notes, sizeof notes, 1, fp); fread(&direction, sizeof direction, 1, fp); fread(&position, sizeof position, 1, fp); fread(&ourtime, sizeof ourtime, 1, fp); fread(&fuel, sizeof fuel, 1, fp); fread(&torps, sizeof torps, 1, fp); fread(&carrying, sizeof carrying, 1, fp); fread(&encumber, sizeof encumber, 1, fp); fread(&rythmn, sizeof rythmn, 1, fp); fread(&followfight, sizeof followfight, 1, fp); fread(&ate, sizeof ate, 1, fp); fread(&snooze, sizeof snooze, 1, fp); fread(&meetgirl, sizeof meetgirl, 1, fp); fread(&followgod, sizeof followgod, 1, fp); fread(&godready, sizeof godready, 1, fp); fread(&win, sizeof win, 1, fp); fread(&wintime, sizeof wintime, 1, fp); fread(&matchlight, sizeof matchlight, 1, fp); fread(&matchcount, sizeof matchcount, 1, fp); fread(&loved, sizeof loved, 1, fp); fread(&pleasure, sizeof pleasure, 1, fp); fread(&power, sizeof power, 1, fp); /* We must check the last read, to catch truncated save files */ if (fread(&ego, sizeof ego, 1, fp) < 1) errx(1, "save file %s too short", filename); fclose(fp); } void save(filename) const char *filename; { int n; int tmp; FILE *fp; if (filename == NULL) return; /* Error determining save file name. */ if ((fp = fopen(filename, "w")) == NULL) { warn("fopen %s", filename); return; } printf("Saved in %s.\n", filename); fwrite(&WEIGHT, sizeof WEIGHT, 1, fp); fwrite(&CUMBER, sizeof CUMBER, 1, fp); fwrite(&ourclock, sizeof ourclock, 1, fp); tmp = location == dayfile; fwrite(&tmp, sizeof tmp, 1, fp); for (n = 1; n <= NUMOFROOMS; n++) { fwrite(location[n].link, sizeof location[n].link, 1, fp); fwrite(location[n].objects, sizeof location[n].objects, 1, fp); } fwrite(inven, sizeof inven, 1, fp); fwrite(wear, sizeof wear, 1, fp); fwrite(injuries, sizeof injuries, 1, fp); fwrite(notes, sizeof notes, 1, fp); fwrite(&direction, sizeof direction, 1, fp); fwrite(&position, sizeof position, 1, fp); fwrite(&ourtime, sizeof ourtime, 1, fp); fwrite(&fuel, sizeof fuel, 1, fp); fwrite(&torps, sizeof torps, 1, fp); fwrite(&carrying, sizeof carrying, 1, fp); fwrite(&encumber, sizeof encumber, 1, fp); fwrite(&rythmn, sizeof rythmn, 1, fp); fwrite(&followfight, sizeof followfight, 1, fp); fwrite(&ate, sizeof ate, 1, fp); fwrite(&snooze, sizeof snooze, 1, fp); fwrite(&meetgirl, sizeof meetgirl, 1, fp); fwrite(&followgod, sizeof followgod, 1, fp); fwrite(&godready, sizeof godready, 1, fp); fwrite(&win, sizeof win, 1, fp); fwrite(&wintime, sizeof wintime, 1, fp); fwrite(&matchlight, sizeof matchlight, 1, fp); fwrite(&matchcount, sizeof matchcount, 1, fp); fwrite(&loved, sizeof loved, 1, fp); fwrite(&pleasure, sizeof pleasure, 1, fp); fwrite(&power, sizeof power, 1, fp); fwrite(&ego, sizeof ego, 1, fp); fflush(fp); if (ferror(fp)) warn("fwrite %s", filename); fclose(fp); } /* * Given a save file name (possibly from fgetln, so without terminating NUL), * determine the name of the file to be saved to by adding the HOME * directory if the name does not contain a slash. Name will be allocated * with malloc(3). */ char * save_file_name(filename, len) const char *filename; size_t len; { char *home; char *newname; size_t tmpl; if (memchr(filename, '/', len)) { newname = malloc(len + 1); if (newname == NULL) { warn(NULL); return NULL; } memcpy(newname, filename, len); newname[len] = 0; } else { home = getenv("HOME"); if (home != NULL) { tmpl = strlen(home); newname = malloc(tmpl + len + 2); if (newname == NULL) { warn(NULL); return NULL; } memcpy(newname, home, tmpl); newname[tmpl] = '/'; memcpy(newname + tmpl + 1, filename, len); newname[tmpl + len + 1] = 0; } else { newname = malloc(len + 1); if (newname == NULL) { warn(NULL); return NULL; } memcpy(newname, filename, len); newname[len] = 0; } } return newname; } bsd-games-2.17/battlestar/pathnames.h.in0000664000175000017500000000332607767741711016727 0ustar jsm28jsm28/* $NetBSD: pathnames.h,v 1.4 2003/08/07 09:37:03 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 5/31/93 */ #define _PATH_SCORE "@battlestar_scorefile@" bsd-games-2.17/battlestar/Makefile.bsd0000664000175000017500000000070107376031146016360 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.9 2001/10/19 03:06:09 tv Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= battlestar SRCS= battlestar.c command1.c command2.c command3.c command4.c \ command5.c command6.c command7.c \ init.c cypher.c getcom.c parse.c room.c save.c fly.c misc.c \ globals.c dayfile.c nightfile.c dayobjs.c nightobjs.c words.c MAN= battlestar.6 DPADD= ${LIBCURSES} LDADD= -lcurses HIDEGAME=hidegame SETGIDGAME=yes .include bsd-games-2.17/battlestar/command2.c0000664000175000017500000002412707767741711016037 0ustar jsm28jsm28/* $NetBSD: command2.c,v 1.2 2003/08/07 09:37:00 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: command2.c,v 1.2 2003/08/07 09:37:00 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" int wearit() { /* synonyms = {sheathe, sheath} */ int firstnumber, value; firstnumber = wordnumber; wordnumber++; while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS) && wordvalue[wordnumber] != DOOR) { value = wordvalue[wordnumber]; if (value >= 0 && objsht[value] == NULL) break; switch (value) { case -1: puts("Wear what?"); return (firstnumber); default: printf("You can't wear %s%s!\n", A_OR_AN_OR_BLANK(value), objsht[value]); return (firstnumber); case KNIFE: /* case SHIRT: */ case ROBE: case LEVIS: /* wearable things */ case SWORD: case MAIL: case HELM: case SHOES: case PAJAMAS: case COMPASS: case LASER: case AMULET: case TALISMAN: case MEDALION: case ROPE: case RING: case BRACELET: case GRENADE: if (testbit(inven, value)) { clearbit(inven, value); setbit(wear, value); carrying -= objwt[value]; encumber -= objcumber[value]; ourtime++; printf("You are now wearing %s%s.\n", A_OR_AN_OR_THE(value), objsht[value]); } else if (testbit(wear, value)) printf("You are already wearing the %s.\n", objsht[value]); else printf("You aren't holding the %s.\n", objsht[value]); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (firstnumber); } /* end switch */ } /* end while */ puts("Don't be ridiculous."); return (firstnumber); } int put() { /* synonyms = {buckle, strap, tie} */ if (wordvalue[wordnumber + 1] == ON) { wordvalue[++wordnumber] = PUTON; wordtype[wordnumber] = VERB; return (cypher()); } if (wordvalue[wordnumber + 1] == DOWN) { wordvalue[++wordnumber] = DROP; wordtype[wordnumber] = VERB; return (cypher()); } puts("I don't understand what you want to put."); return (-1); } int draw() { /* synonyms = {pull, carry} */ return (take(wear)); } int use() { wordnumber++; if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) && position != FINAL) { puts("The amulet begins to glow."); if (testbit(inven, MEDALION)) { puts("The medallion comes to life too."); if (position == 114) { location[position].down = 160; whichway(location[position]); puts("The waves subside and it is possible to descend to the sea cave now."); ourtime++; return (-1); } } puts("A light mist falls over your eyes and the sound of purling water trickles in"); puts("your ears. When the mist lifts you are standing beside a cool stream."); if (position == 229) position = 224; else position = 229; ourtime++; notes[CANTSEE] = 0; return (0); } else if (position == FINAL) puts("The amulet won't work in here."); else if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS)) printf("Your compass points %s.\n", truedirec(NORTH, '-')); else if (wordvalue[wordnumber] == COMPASS) puts("You aren't holding the compass."); else if (wordvalue[wordnumber] == AMULET) puts("You aren't holding the amulet."); else puts("There is no apparent use."); return (-1); } void murder() { int n; for (n = 0; !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || n == HALBERD) && testbit(inven, n)) && n < NUMOFOBJECTS; n++); if (n == NUMOFOBJECTS) { if (testbit(inven, LASER)) { printf("Your laser should do the trick.\n"); wordnumber++; switch(wordvalue[wordnumber]) { case NORMGOD: case TIMER: case NATIVE: case MAN: wordvalue[--wordnumber] = SHOOT; cypher(); break; case -1: puts("Kill what?"); break; default: if (wordtype[wordnumber] != OBJECT || wordvalue[wordnumber] == EVERYTHING) puts("You can't kill that!"); else printf("You can't kill %s%s!\n", A_OR_AN_OR_BLANK(wordvalue[wordnumber]), objsht[wordvalue[wordnumber]]); break; } } else puts("You don't have suitable weapons to kill."); } else { printf("Your %s should do the trick.\n", objsht[n]); wordnumber++; switch (wordvalue[wordnumber]) { case NORMGOD: if (testbit(location[position].objects, BATHGOD)) { puts("The goddess's head slices off. Her corpse floats in the water."); clearbit(location[position].objects, BATHGOD); setbit(location[position].objects, DEADGOD); power += 5; notes[JINXED]++; } else if (testbit(location[position].objects, NORMGOD)) { puts("The goddess pleads but you strike her mercilessly. Her broken body lies in a\npool of blood."); clearbit(location[position].objects, NORMGOD); setbit(location[position].objects, DEADGOD); power += 5; notes[JINXED]++; if (wintime) live(); } else puts("I don't see her anywhere."); break; case TIMER: if (testbit(location[position].objects, TIMER)) { puts("The old man offers no resistance."); clearbit(location[position].objects, TIMER); setbit(location[position].objects, DEADTIME); power++; notes[JINXED]++; } else puts("Who?"); break; case NATIVE: if (testbit(location[position].objects, NATIVE)) { puts("The girl screams as you cut her body to shreds. She is dead."); clearbit(location[position].objects, NATIVE); setbit(location[position].objects, DEADNATIVE); power += 5; notes[JINXED]++; } else puts("What girl?"); break; case MAN: if (testbit(location[position].objects, MAN)) { puts("You strike him to the ground, and he coughs up blood."); puts("Your fantasy is over."); die(); } case -1: puts("Kill what?"); break; default: if (wordtype[wordnumber] != OBJECT || wordvalue[wordnumber] == EVERYTHING) puts("You can't kill that!"); else printf("You can't kill the %s!\n", objsht[wordvalue[wordnumber]]); } } } void ravage() { while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount) continue; if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, wordvalue[wordnumber]) || (wordvalue[wordnumber] == NORMGOD && testbit(location[position].objects, BATHGOD)))) { ourtime++; switch (wordvalue[wordnumber]) { case NORMGOD: puts("You attack the goddess, and she screams as you beat her. She falls down"); if (testbit(location[position].objects, BATHGOD)) puts("crying and tries to cover her nakedness."); else puts("crying and tries to hold her torn and bloodied dress around her."); power += 5; pleasure += 8; ego -= 10; wordnumber--; godready = -30000; murder(); win = -30000; break; case NATIVE: puts("The girl tries to run, but you catch her and throw her down. Her face is"); puts("bleeding, and she screams as you tear off her clothes."); power += 3; pleasure += 5; ego -= 10; wordnumber--; murder(); if (rnd(100) < 50) { puts("Her screams have attracted attention. I think we are surrounded."); setbit(location[ahead].objects, WOODSMAN); setbit(location[ahead].objects, DEADWOOD); setbit(location[ahead].objects, MALLET); setbit(location[back].objects, WOODSMAN); setbit(location[back].objects, DEADWOOD); setbit(location[back].objects, MALLET); setbit(location[left].objects, WOODSMAN); setbit(location[left].objects, DEADWOOD); setbit(location[left].objects, MALLET); setbit(location[right].objects, WOODSMAN); setbit(location[right].objects, DEADWOOD); setbit(location[right].objects, MALLET); } break; default: puts("You are perverted."); } } else puts("Who?"); } int follow() { if (followfight == ourtime) { puts("The Dark Lord leaps away and runs down secret tunnels and corridors."); puts("You chase him through the darkness and splash in pools of water."); puts("You have cornered him. His laser sword extends as he steps forward."); position = FINAL; fight(DARK, 75); setbit(location[position].objects, TALISMAN); setbit(location[position].objects, AMULET); return (0); } else if (followgod == ourtime) { puts("The goddess leads you down a steamy tunnel and into a high, wide chamber."); puts("She sits down on a throne."); position = 268; setbit(location[position].objects, NORMGOD); notes[CANTSEE] = 1; return (0); } else puts("There is no one to follow."); return (-1); } bsd-games-2.17/battlestar/command3.c0000664000175000017500000002127307767741711016037 0ustar jsm28jsm28/* $NetBSD: command3.c,v 1.2 2003/08/07 09:37:00 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: command3.c,v 1.2 2003/08/07 09:37:00 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" void dig() { if (testbit(inven, SHOVEL)) { puts("OK"); ourtime++; switch (position) { case 144: /* copse near beach */ if (!notes[DUG]) { setbit(location[position].objects, DEADWOOD); setbit(location[position].objects, COMPASS); setbit(location[position].objects, KNIFE); setbit(location[position].objects, MACE); notes[DUG] = 1; } break; default: puts("Nothing happens."); } } else puts("You don't have a shovel."); } int jump() { int n; switch (position) { default: puts("Nothing happens."); return (-1); case 242: position = 133; break; case 214: case 215: case 162: case 159: position = 145; break; case 232: position = FINAL; break; case 3: position = 1; break; case 172: position = 201; } puts("Ahhhhhhh..."); injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) { clearbit(inven, n); setbit(location[position].objects, n); } carrying = 0; encumber = 0; return (0); } void bury() { int value; if (testbit(inven, SHOVEL)) { while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount) continue; value = wordvalue[wordnumber]; if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, value) || value == BODY)) switch (value) { case BODY: wordtype[wordnumber] = OBJECT; if (testbit(inven, MAID) || testbit(location[position].objects, MAID)) value = MAID; if (testbit(inven, DEADWOOD) || testbit(location[position].objects, DEADWOOD)) value = DEADWOOD; if (testbit(inven, DEADGOD) || testbit(location[position].objects, DEADGOD)) value = DEADGOD; if (testbit(inven, DEADTIME) || testbit(location[position].objects, DEADTIME)) value = DEADTIME; if (testbit(inven, DEADNATIVE) || testbit(location[position].objects, DEADNATIVE)) value = DEADNATIVE; break; case NATIVE: case NORMGOD: puts("She screams as you wrestle her into the hole."); case TIMER: power += 7; ego -= 10; case AMULET: case MEDALION: case TALISMAN: wordtype[wordnumber] = OBJECT; break; default: puts("Wha..?"); } if (wordtype[wordnumber] == OBJECT && position > 88 && (testbit(inven, value) || testbit(location[position].objects, value))) { puts("Buried."); if (testbit(inven, value)) { clearbit(inven, value); carrying -= objwt[value]; encumber -= objcumber[value]; } clearbit(location[position].objects, value); switch (value) { case MAID: case DEADWOOD: case DEADNATIVE: case DEADTIME: case DEADGOD: ego += 2; printf("The %s should rest easier now.\n", objsht[value]); } } else puts("It doesn't seem to work."); } else puts("You aren't holding a shovel."); } void drink() { int n; if (testbit(inven, POTION)) { puts("The cool liquid runs down your throat but turns to fire and you choke."); puts("The heat reaches your limbs and tingles your spirit. You feel like falling"); puts("asleep."); clearbit(inven, POTION); WEIGHT = MAXWEIGHT; CUMBER = MAXCUMBER; for (n = 0; n < NUMOFINJURIES; n++) injuries[n] = 0; ourtime++; zzz(); } else puts("I'm not thirsty."); } int shoot() { int firstnumber, value; firstnumber = wordnumber; if (!testbit(inven, LASER)) puts("You aren't holding a blaster."); else { wordnumber++; while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) { value = wordvalue[wordnumber]; printf("%s:\n", objsht[value]); if (testbit(location[position].objects, value)) { clearbit(location[position].objects, value); ourtime++; printf("The %s explode%s\n", objsht[value], (is_plural_object(value) ? "." : "s.")); if (value == BOMB) die(); } else printf("I don't see any %s around here.\n", objsht[value]); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (firstnumber); } /* special cases with their own return()'s */ if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) { ourtime++; switch (wordvalue[wordnumber]) { case DOOR: switch (position) { case 189: case 231: puts("The door is unhinged."); location[189].north = 231; location[231].south = 189; whichway(location[position]); break; case 30: puts("The wooden door splinters."); location[30].west = 25; whichway(location[position]); break; case 31: puts("The laser blast has no effect on the door."); break; case 20: puts("The blast hits the door and it explodes into flame. The magnesium burns"); puts("so rapidly that we have no chance to escape."); die(); default: puts("Nothing happens."); } break; case NORMGOD: if (testbit(location[position].objects, BATHGOD)) { puts("The goddess is hit in the chest and splashes back against the rocks."); puts("Dark blood oozes from the charred blast hole. Her naked body floats in the"); puts("pools and then off downstream."); clearbit(location[position].objects, BATHGOD); setbit(location[180].objects, DEADGOD); power += 5; ego -= 10; notes[JINXED]++; } else if (testbit(location[position].objects, NORMGOD)) { puts("The blast catches the goddess in the stomach, knocking her to the ground."); puts("She writhes in the dirt as the agony of death taunts her."); puts("She has stopped moving."); clearbit(location[position].objects, NORMGOD); setbit(location[position].objects, DEADGOD); power += 5; ego -= 10; notes[JINXED]++; if (wintime) live(); break; } else puts("I don't see any goddess around here."); break; case TIMER: if (testbit(location[position].objects, TIMER)) { puts("The old man slumps over the bar."); power++; ego -= 2; notes[JINXED]++; clearbit(location[position].objects, TIMER); setbit(location[position].objects, DEADTIME); } else puts("What old-timer?"); break; case MAN: if (testbit(location[position].objects, MAN)) { puts("The man falls to the ground with blood pouring all over his white suit."); puts("Your fantasy is over."); die(); } else puts("What man?"); break; case NATIVE: if (testbit(location[position].objects, NATIVE)) { puts("The girl is blown backwards several feet and lies in a pool of blood."); clearbit(location[position].objects, NATIVE); setbit(location[position].objects, DEADNATIVE); power += 5; ego -= 2; notes[JINXED]++; } else puts("There is no girl here."); break; case -1: puts("Shoot what?"); break; default: printf("You can't shoot the %s.\n", objsht[wordvalue[wordnumber]]); } } else puts("You must be a looney."); } return (firstnumber); } bsd-games-2.17/battlestar/command4.c0000664000175000017500000002770707767741711016050 0ustar jsm28jsm28/* $NetBSD: command4.c,v 1.2 2003/08/07 09:37:00 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)com4.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: command4.c,v 1.2 2003/08/07 09:37:00 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" int take(from) unsigned int from[]; { int firstnumber, heavy, bulky, value; firstnumber = wordnumber; if (wordnumber < wordcount && wordvalue[wordnumber + 1] == OFF) { wordnumber++; wordvalue[wordnumber] = TAKEOFF; wordtype[wordnumber] = VERB; return (cypher()); } else { wordnumber++; while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) { value = wordvalue[wordnumber]; printf("%s:\n", objsht[value]); heavy = (carrying + objwt[value]) <= WEIGHT; bulky = (encumber + objcumber[value]) <= CUMBER; if ((testbit(from, value) || wiz || tempwiz) && heavy && bulky && !testbit(inven, value)) { setbit(inven, value); carrying += objwt[value]; encumber += objcumber[value]; ourtime++; if (testbit(from, value)) printf("Taken.\n"); else printf("Zap! Taken from thin air.\n"); clearbit(from, value); if (value == MEDALION) win--; } else if (testbit(inven, value)) printf("You're already holding %s%s.\n", A_OR_AN_OR_BLANK(value), objsht[value]); else if (!testbit(from, value)) printf("I don't see any %s around here.\n", objsht[value]); else if (!heavy) printf("The %s %stoo heavy.\n", objsht[value], IS_OR_ARE(value)); else printf("The %s %stoo cumbersome to hold.\n", objsht[value], IS_OR_ARE(value)); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (firstnumber); } } /* special cases with their own return()'s */ if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) switch (wordvalue[wordnumber]) { case SWORD: if (testbit(from, SWORD)) { wordtype[wordnumber--] = OBJECT; return (take(from)); } if (testbit(from, TWO_HANDED)) { wordvalue[wordnumber] = TWO_HANDED; wordtype[wordnumber--] = OBJECT; return (take(from)); } wordvalue[wordnumber] = BROAD; wordtype[wordnumber--] = OBJECT; return (take(from)); case BODY: if (testbit(from, MAID)) { wordvalue[wordnumber] = MAID; wordtype[wordnumber--] = OBJECT; return (take(from)); } else if (testbit(from, DEADWOOD)) { wordvalue[wordnumber] = DEADWOOD; wordtype[wordnumber--] = OBJECT; return (take(from)); } else if (testbit(from, DEADNATIVE)) { wordvalue[wordnumber] = DEADNATIVE; wordtype[wordnumber--] = OBJECT; return (take(from)); } else { if (testbit(from, DEADGOD)) { wordvalue[wordnumber] = DEADGOD; wordtype[wordnumber--] = OBJECT; return (take(from)); } else { wordvalue[wordnumber] = DEADTIME; wordtype[wordnumber--] = OBJECT; return (take(from)); } } break; case AMULET: if (testbit(location[position].objects, AMULET)) { puts("The amulet is warm to the touch, and its beauty catches your breath."); puts("A mist falls over your eyes, but then it is gone. Sounds seem clearer"); puts("and sharper but far away as if in a dream. The sound of purling water"); puts("reaches you from afar. The mist falls again, and your heart leaps in horror."); puts("The gold freezes your hands and fathomless darkness engulfs your soul."); } wordtype[wordnumber--] = OBJECT; return (take(from)); case MEDALION: if (testbit(location[position].objects, MEDALION)) { puts("The medallion is warm, and it rekindles your spirit with the warmth of life."); puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate."); } wordtype[wordnumber--] = OBJECT; return (take(from)); case TALISMAN: if (testbit(location[position].objects, TALISMAN)) { puts("The talisman is cold to the touch, and it sends a chill down your spine."); } wordtype[wordnumber--] = OBJECT; return (take(from)); case NORMGOD: if (testbit(location[position].objects, BATHGOD) && (testbit(wear, AMULET) || testbit(inven, AMULET))) { puts("She offers a delicate hand, and you help her out of the sparkling springs."); puts("Water droplets like liquid silver bedew her golden skin, but when they part"); puts("from her, they fall as teardrops. She wraps a single cloth around her and"); puts("ties it at the waist. Around her neck hangs a golden amulet."); puts("She bids you to follow her, and walks away."); pleasure++; followgod = ourtime; clearbit(location[position].objects, BATHGOD); } else if (!testbit(location[position].objects, BATHGOD)) puts("You're in no position to take her."); else puts("She moves away from you."); break; default: puts("It doesn't seem to work."); } else puts("You've got to be kidding."); return (firstnumber); } int throw(name) const char *name; { unsigned int n; int deposit = 0; int first, value; first = wordnumber; if (drop(name) != -1) { switch (wordvalue[wordnumber]) { case AHEAD: deposit = ahead; break; case BACK: deposit = back; break; case LEFT: deposit = left; break; case RIGHT: deposit = right; break; case UP: deposit = location[position].up * (location[position].access || position == FINAL); break; case DOWN: deposit = location[position].down; break; } wordnumber = first + 1; while (wordnumber <= wordcount) { value = wordvalue[wordnumber]; if (deposit && testbit(location[position].objects, value)) { clearbit(location[position].objects, value); if (value != GRENADE) setbit(location[deposit].objects, value); else { puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel."); for (n = 0; n < NUMOFWORDS; n++) location[deposit].objects[n] = 0; setbit(location[deposit].objects, CHAR); } if (value == ROPE && position == FINAL) location[position].access = 1; switch (deposit) { case 189: case 231: puts("The stone door is unhinged."); location[189].north = 231; location[231].south = 189; break; case 30: puts("The wooden door is blown open."); location[30].west = 25; break; case 31: puts("The door is not damaged."); } } else if (value == GRENADE && testbit(location[position].objects, value)) { puts("You are blown into shreds when your grenade explodes."); die(); } if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (first); } return (first); } return (first); } int drop(name) const char *name; { int firstnumber, value; firstnumber = wordnumber; wordnumber++; while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) { value = wordvalue[wordnumber]; if (value == BODY) { /* special case */ wordtype[wordnumber] = OBJECT; if (testbit(inven, MAID) || testbit(location[position].objects, MAID)) value = MAID; else if (testbit(inven, DEADWOOD) || testbit(location[position].objects, DEADWOOD)) value = DEADWOOD; else if (testbit(inven, DEADGOD) || testbit(location[position].objects, DEADGOD)) value = DEADGOD; else if (testbit(inven, DEADTIME) || testbit(location[position].objects, DEADTIME)) value = DEADTIME; else if (testbit(inven, DEADNATIVE) || testbit(location[position].objects, DEADNATIVE)) value = DEADNATIVE; } if (wordtype[wordnumber] == NOUNS && value == DOOR) { if (*name == 'K') puts("You hurt your foot."); else puts("You're not holding a door."); } else if (objsht[value] == NULL) { if (*name == 'K') puts("That's not for kicking!"); else puts("You don't have that."); } else { printf("%s:\n", objsht[value]); if (testbit(inven, value)) { clearbit(inven, value); carrying -= objwt[value]; encumber -= objcumber[value]; if (value == BOMB) { puts("The bomb explodes. A blinding white light and immense concussion obliterate us."); die(); } if (value != AMULET && value != MEDALION && value != TALISMAN) setbit(location[position].objects, value); else tempwiz = 0; ourtime++; if (*name == 'K') puts("Drop kicked."); else printf("%s.\n", name); } else { if (*name != 'K') { printf("You aren't holding the %s.\n", objsht[value]); if (testbit(location[position].objects, value)) { if (*name == 'T') puts("Kicked instead."); else if (*name == 'G') puts("Given anyway."); } } else if (testbit(location[position].objects, value)) puts("Kicked."); else if (testbit(wear, value)) puts("Not while it's being worn."); else puts("Not found."); } } if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (firstnumber); } puts("Do what?"); return (-1); } int takeoff() { wordnumber = take(wear); return (drop("Dropped")); } int puton() { wordnumber = take(location[position].objects); return (wearit()); } int eat() { int firstnumber, value; firstnumber = wordnumber; wordnumber++; while (wordnumber <= wordcount) { value = wordvalue[wordnumber]; if (wordtype[wordnumber] != OBJECT || objsht[value] == NULL) value = -2; switch (value) { case -2: puts("You can't eat that!"); return (firstnumber); case -1: puts("Eat what?"); return (firstnumber); default: printf("You can't eat %s%s!\n", A_OR_AN_OR_BLANK(value), objsht[value]); return (firstnumber); case PAPAYAS: case PINEAPPLE: case KIWI: case COCONUTS: /* eatable things */ case MANGO: printf("%s:\n", objsht[value]); if (testbit(inven, value) && ourtime > ate - CYCLE && testbit(inven, KNIFE)) { clearbit(inven, value); carrying -= objwt[value]; encumber -= objcumber[value]; ate = max(ourtime, ate) + CYCLE / 3; snooze += CYCLE / 10; ourtime++; puts("Eaten. You can explore a little longer now."); } else if (!testbit(inven, value)) printf("You aren't holding the %s.\n", objsht[value]); else if (!testbit(inven, KNIFE)) puts("You need a knife."); else puts("You're stuffed."); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (firstnumber); } /* end switch */ } /* end while */ return (firstnumber); } bsd-games-2.17/battlestar/command5.c0000664000175000017500000002774007767741711016046 0ustar jsm28jsm28/* $NetBSD: command5.c,v 1.2 2003/08/07 09:37:00 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)com5.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: command5.c,v 1.2 2003/08/07 09:37:00 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" void kiss() { while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount) continue; /* The goddess must be "taken" first if bathing. */ if (wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] == NORMGOD && testbit(location[position].objects, BATHGOD)) { wordvalue[--wordnumber] = TAKE; cypher(); return; } if (wordtype[wordnumber] == NOUNS) { if (testbit(location[position].objects, wordvalue[wordnumber])) { pleasure++; printf("Kissed.\n"); switch (wordvalue[wordnumber]) { case NORMGOD: switch (godready++) { case 0: puts("She squirms and avoids your advances."); break; case 1: puts("She is coming around; she didn't fight it as much."); break; case 2: puts("She's beginning to like it."); break; default: puts("She's gone limp."); } break; case NATIVE: puts("Her lips are warm and her body robust. She pulls you down to the ground."); break; case TIMER: puts("The old man blushes."); break; case MAN: puts("The dwarf punches you in the kneecap."); break; default: pleasure--; } } else puts("I see nothing like that here."); } else puts("I'd prefer not to."); } void love() { int n; while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount) continue; if (wordtype[wordnumber] == NOUNS) { if ((testbit(location[position].objects, BATHGOD) || testbit(location[position].objects, NORMGOD)) && wordvalue[wordnumber] == NORMGOD) { if (loved) { printf("Loved.\n"); return; } if (godready >= 2) { puts("She cuddles up to you, and her mouth starts to work:\n'That was my sister's amulet. The lovely goddess, Purl, was she. The Empire\ncaptured her just after the Darkness came. My other sister, Vert, was killed\nby the Dark Lord himself. He took her amulet and warped its power.\nYour quest was foretold by my father before he died, but to get the Dark Lord's\namulet you must use cunning and skill. I will leave you my amulet,"); puts("which you may use as you wish. As for me, I am the last goddess of the\nwaters. My father was the Island King, and the rule is rightfully mine.'\n\nShe pulls the throne out into a large bed."); power++; pleasure += 15; ego++; if (card(injuries, NUMOFINJURIES)) { puts("Her kisses revive you; your wounds are healed.\n"); for (n = 0; n < NUMOFINJURIES; n++) injuries[n] = 0; WEIGHT = MAXWEIGHT; CUMBER = MAXCUMBER; } printf("Goddess:\n"); if (!loved) setbit(location[position].objects, MEDALION); loved = 1; ourtime += 10; printf("Loved.\n"); zzz(); return; } else { puts("You wish!"); return; } } if (testbit(location[position].objects, wordvalue[wordnumber])) { if (wordvalue[wordnumber] == NATIVE) { puts("The girl is easy prey. She peels off her sarong and indulges you."); power++; pleasure += 5; printf("Girl:\n"); ourtime += 10; printf("Loved.\n"); zzz(); } if (wordvalue[wordnumber] == MAN || wordvalue[wordnumber] == BODY || wordvalue[wordnumber] == ELF || wordvalue[wordnumber] == TIMER) puts("Kinky!"); else puts("It doesn't seem to work."); } else puts("Where's your lover?"); } else puts("It doesn't seem to work."); } int zzz() { int oldtime; int n; oldtime = ourtime; if ((snooze - ourtime) < (0.75 * CYCLE)) { ourtime += 0.75 * CYCLE - (snooze - ourtime); printf(""); for (n = 0; n < ourtime - oldtime; n++) printf("."); printf("\n"); snooze += 3 * (ourtime - oldtime); if (notes[LAUNCHED]) { fuel -= (ourtime - oldtime); if (location[position].down) { position = location[position].down; crash(); } else notes[LAUNCHED] = 0; } if (OUTSIDE && rnd(100) < 50) { puts("You are awakened abruptly by the sound of someone nearby."); switch (rnd(4)) { case 0: if (ucard(inven)) { n = rnd(NUMOFOBJECTS); while (!testbit(inven, n)) n = rnd(NUMOFOBJECTS); clearbit(inven, n); if (n != AMULET && n != MEDALION && n != TALISMAN) setbit(location[position].objects, n); carrying -= objwt[n]; encumber -= objcumber[n]; } puts("A fiendish little Elf is stealing your treasures!"); fight(ELF, 10); break; case 1: setbit(location[position].objects, DEADWOOD); break; case 2: setbit(location[position].objects, HALBERD); break; default: break; } } } else return (0); return (1); } void chime() { if ((ourtime / CYCLE + 1) % 2 && OUTSIDE) switch ((ourtime % CYCLE) / (CYCLE / 7)) { case 0: puts("It is just after sunrise."); break; case 1: puts("It is early morning."); break; case 2: puts("It is late morning."); break; case 3: puts("It is near noon."); break; case 4: puts("It is early afternoon."); break; case 5: puts("It is late afternoon."); break; case 6: puts("It is near sunset."); break; } else if (OUTSIDE) switch ((ourtime % CYCLE) / (CYCLE / 7)) { case 0: puts("It is just after sunset."); break; case 1: puts("It is early evening."); break; case 2: puts("The evening is getting old."); break; case 3: puts("It is near midnight."); break; case 4: puts("These are the wee hours of the morning."); break; case 5: puts("The night is waning."); break; case 6: puts("It is almost morning."); break; } else puts("I can't tell the time in here."); } int give() { int obj = -1, result = -1, person = 0, firstnumber, last1, last2; last1 = last2 = 0; firstnumber = wordnumber; while (wordtype[++wordnumber] != OBJECT && wordvalue[wordnumber] != AMULET && wordvalue[wordnumber] != MEDALION && wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount) continue; if (wordnumber <= wordcount) { obj = wordvalue[wordnumber]; if (obj == EVERYTHING) wordtype[wordnumber] = -1; last1 = wordnumber; } wordnumber = firstnumber; while ((wordtype[++wordnumber] != NOUNS || wordvalue[wordnumber] == obj) && wordnumber <= wordcount); if (wordtype[wordnumber] == NOUNS) { person = wordvalue[wordnumber]; last2 = wordnumber; } /* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g., * plain `give'. However, detecting this case is liable to detect * `give foo' as well, which would give a confusing error. We * need to make sure the -1 value can cause no problems if it arises. * If in the below we get to the drop("Given") then drop will look * at word 0 for an object to give, and fail, which is OK; then * result will be -1 and we get to the end, where wordnumber gets * set to something more sensible. If we get to "I don't think * that is possible" then again wordnumber is set to something * sensible. The wordnumber we leave with still isn't right if * you include words the game doesn't know in your command, but * that's no worse than what other commands than give do in * the same place. */ wordnumber = last1 - 1; if (person && testbit(location[position].objects, person)) { if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET)) puts("The goddess won't look at you."); else result = drop("Given"); } else { puts("I don't think that is possible."); wordnumber = max(last1, last2) + 1; return (0); } if (result != -1 && (testbit(location[position].objects, obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)) { clearbit(location[position].objects, obj); ourtime++; ego++; switch (person) { case NATIVE: puts("She accepts it shyly."); ego += 2; break; case NORMGOD: if (obj == RING || obj == BRACELET) { puts("She takes the charm and puts it on. A little kiss on the cheek is"); puts("your reward."); ego += 5; godready += 3; } if (obj == AMULET || obj == MEDALION || obj == TALISMAN) { win++; ego += 5; power -= 5; if (win >= 3) { puts("The powers of the earth are now legitimate. You have destroyed the Darkness"); puts("and restored the goddess to her throne. The entire island celebrates with"); puts("dancing and spring feasts. As a measure of her gratitude, the goddess weds you"); puts("in the late summer and crowns you Prince Liverwort, Lord of Fungus."); puts("\nBut, as the year wears on and autumn comes along, you become restless and"); puts("yearn for adventure. The goddess, too, realizes that the marriage can't last."); puts("She becomes bored and takes several more natives as husbands. One evening,"); puts("after having been out drinking with the girls, she kicks the throne particularly"); puts("hard and wakes you up. (If you want to win this game, you're going to have to\nshoot her!)"); clearbit(location[position].objects, MEDALION); wintime = ourtime; } } break; case TIMER: if (obj == COINS) { puts("He fingers the coins for a moment and then looks up agape. `Kind you are and"); puts("I mean to repay you as best I can.' Grabbing a pencil and cocktail napkin...\n"); printf("+-----------------------------------------------------------------------------+\n"); printf("| xxxxxxxx\\ |\n"); printf("| xxxxx\\ CLIFFS |\n"); printf("| FOREST xxx\\ |\n"); printf("| \\\\ x\\ OCEAN |\n"); printf("| || x\\ |\n"); printf("| || ROAD x\\ |\n"); printf("| || x\\ |\n"); printf("| SECRET || ......... |\n"); printf("| - + - || ........ |\n"); printf("| ENTRANCE || ... BEACH |\n"); printf("| || ... E |\n"); printf("| || ... | |\n"); printf("| // ... N <-- + --- S |\n"); printf("| PALM GROVE // ... | |\n"); printf("| // ... W |\n"); printf("+-----------------------------------------------------------------------------+\n"); puts("\n`This map shows a secret entrance to the catacombs."); puts("You will know when you arrive because I left an old pair of shoes there.'"); } break; } } wordnumber = max(last1, last2) + 1; return (firstnumber); } bsd-games-2.17/battlestar/command6.c0000664000175000017500000001523507767741711016043 0ustar jsm28jsm28/* $NetBSD: command6.c,v 1.2 2003/08/07 09:37:01 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: command6.c,v 1.2 2003/08/07 09:37:01 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" #include "pathnames.h" int launch() { if (testbit(location[position].objects, VIPER) && !notes[CANTLAUNCH]) { if (fuel > 4) { clearbit(location[position].objects, VIPER); position = location[position].up; notes[LAUNCHED] = 1; ourtime++; fuel -= 4; puts("You climb into the viper and prepare for launch."); puts("With a touch of your thumb the turbo engines ignite, thrusting you back into\nyour seat."); return (1); } else puts("Not enough fuel to launch."); } else puts("Can't launch."); return (0); } int land() { if (notes[LAUNCHED] && testbit(location[position].objects, LAND) && location[position].down) { notes[LAUNCHED] = 0; position = location[position].down; setbit(location[position].objects, VIPER); fuel -= 2; ourtime++; puts("You are down."); return (1); } else puts("You can't land here."); return (0); } void die() { /* endgame */ printf("bye.\nYour rating was %s.\n", rate()); post(' '); exit(0); } void diesig(dummy) int dummy __attribute__((__unused__)); { die(); } void live() { puts("\nYou win!"); post('!'); exit(0); } static FILE *score_fp; void open_score_file() { score_fp = fopen(_PATH_SCORE, "a"); if (score_fp == NULL && getenv("BATTLESTAR_QUIET") == NULL) warn("open %s for append", _PATH_SCORE); if (score_fp != NULL && fileno(score_fp) < 3) exit(1); } void post(ch) char ch; { time_t tv; char *date; sigset_t sigset, osigset; sigemptyset(&sigset); sigaddset(&sigset, SIGINT); sigprocmask(SIG_BLOCK, &sigset, &osigset); tv = time(NULL); date = ctime(&tv); date[24] = '\0'; if (score_fp != NULL) { fprintf(score_fp, "%s %8s %c%20s", date, username, ch, rate()); if (wiz) fprintf(score_fp, " wizard\n"); else if (tempwiz) fprintf(score_fp, " WIZARD!\n"); else fprintf(score_fp, "\n"); } sigprocmask(SIG_SETMASK, &osigset, (sigset_t *) 0); } const char * rate() { int score; score = max(max(pleasure, power), ego); if (score == pleasure) { if (score < 5) return ("novice"); else if (score < 20) return ("junior voyeur"); else if (score < 35) return ("Don Juan"); else return ("Marquis De Sade"); } else if (score == power) { if (score < 5) return ("serf"); else if (score < 8) return ("Samurai"); else if (score < 13) return ("Klingon"); else if (score < 22) return ("Darth Vader"); else return ("Sauron the Great"); } else { if (score < 5) return ("Polyanna"); else if (score < 10) return ("philanthropist"); else if (score < 20) return ("Tattoo"); else return ("Mr. Roarke"); } } int drive() { if (testbit(location[position].objects, CAR)) { puts("You hop in the car and turn the key. There is a perceptible grating noise,"); puts("and an explosion knocks you unconscious..."); clearbit(location[position].objects, CAR); setbit(location[position].objects, CRASH); injuries[5] = injuries[6] = injuries[7] = injuries[8] = 1; ourtime += 15; zzz(); return (0); } else puts("There is nothing to drive here."); return (-1); } int ride() { if (testbit(location[position].objects, HORSE)) { puts("You climb onto the stallion and kick it in the guts. The stupid steed launches"); puts("forward through bush and fern. You are thrown and the horse gallops off."); clearbit(location[position].objects, HORSE); while (!(position = rnd(NUMOFROOMS + 1)) || !OUTSIDE || !beenthere[position] || location[position].flyhere) continue; setbit(location[position].objects, HORSE); if (location[position].north) position = location[position].north; else if (location[position].south) position = location[position].south; else if (location[position].east) position = location[position].east; else position = location[position].west; return (0); } else puts("There is no horse here."); return (-1); } void light() { /* synonyms = {strike, smoke} *//* for * matches, cigars */ if (testbit(inven, MATCHES) && matchcount) { puts("Your match splutters to life."); ourtime++; matchlight = 1; matchcount--; if (position == 217) { puts("The whole bungalow explodes with an intense blast."); die(); } } else puts("You're out of matches."); } void dooropen() { /* synonyms = {open, unlock} */ wordnumber++; if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] == DOOR) { switch(position) { case 189: case 231: if (location[189].north == 231) puts("The door is already open."); else puts("The door does not budge."); break; case 30: if (location[30].west == 25) puts("The door is gone."); else puts("The door is locked tight."); break; case 31: puts("That's one immovable door."); break; case 20: puts("The door is already ajar."); break; default: puts("What door?"); } } else puts("That doesn't open."); } bsd-games-2.17/battlestar/init.c0000664000175000017500000000752210005547567015272 0ustar jsm28jsm28/* $NetBSD: init.c,v 1.14 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95"; #else __RCSID("$NetBSD: init.c,v 1.14 2004/01/27 20:30:29 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" static int checkout(const char *); static const char *getutmp(void); static int wizard(const char *); void initialize(filename) const char *filename; { const struct objs *p; char *savefile; puts("Version 4.2, fall 1984."); puts("First Adventure game written by His Lordship, the honorable"); puts("Admiral D.W. Riggle\n"); location = dayfile; srand(getpid()); username = getutmp(); wordinit(); if (filename == NULL) { direction = NORTH; ourtime = 0; snooze = CYCLE * 1.5; position = 22; setbit(wear, PAJAMAS); fuel = TANKFULL; torps = TORPEDOES; for (p = dayobjs; p->room != 0; p++) setbit(location[p->room].objects, p->obj); } else { savefile = save_file_name(filename, strlen(filename)); restore(savefile); free(savefile); } wiz = wizard(username); signal(SIGINT, diesig); } static const char * getutmp() { struct passwd *ptr; ptr = getpwuid(getuid()); if (ptr == NULL) return ""; else return strdup(ptr->pw_name); } /* Hereditary wizards. A configuration file might make more sense. */ static const char *const list[] = { "riggle", "chris", "edward", "comay", "yee", "dmr", "ken", 0 }; static const char *const badguys[] = { "wnj", "root", "ted", 0 }; static int wizard(uname) const char *uname; { int flag; if ((flag = checkout(uname)) != 0) printf("You are the Great wizard %s.\n", uname); return flag; } static int checkout(uname) const char *uname; { const char *const *ptr; for (ptr = list; *ptr; ptr++) if (strcmp(*ptr, uname) == 0) return 1; for (ptr = badguys; *ptr; ptr++) if (strcmp(*ptr, uname) == 0) { printf("You are the Poor anti-wizard %s. Good Luck!\n", uname); CUMBER = 3; WEIGHT = 9; /* that'll get him! */ ourclock = 10; setbit(location[7].objects, WOODSMAN); /* viper room */ setbit(location[20].objects, WOODSMAN); /* laser " */ setbit(location[13].objects, DARK); /* amulet " */ setbit(location[8].objects, ELF); /* closet */ return 0; /* anything else, Chris? */ } return 0; } bsd-games-2.17/battlestar/battlestar.c0000664000175000017500000000656110005547567016476 0ustar jsm28jsm28/* $NetBSD: battlestar.c,v 1.14 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\ The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)battlestar.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: battlestar.c,v 1.14 2004/01/27 20:30:29 jsm Exp $"); #endif #endif /* not lint */ /* * Battlestar - a stellar-tropical adventure game * * Originally written by His Lordship, Admiral David W. Horatio Riggle, * on the Cory PDP-11/70, University of California, Berkeley. */ #include "extern.h" int main(int, char *[]); int main(argc, argv) int argc; char **argv; { char mainbuf[LINELENGTH]; char *next; /* Open the score file then revoke setgid privileges */ open_score_file(); setregid(getgid(), getgid()); if (argc < 2) initialize(NULL); else if (strcmp(argv[1], "-r") == 0) initialize((argc > 2) ? argv[2] : DEFAULT_SAVE_FILE); else initialize(argv[1]); start: news(); if (beenthere[position] <= ROOMDESC) beenthere[position]++; if (notes[LAUNCHED]) crash(); /* decrements fuel & crash */ if (matchlight) { puts("Your match splutters out."); matchlight = 0; } if (!notes[CANTSEE] || testbit(inven, LAMPON) || testbit(location[position].objects, LAMPON)) { writedes(); printobjs(); } else puts("It's too dark to see anything in here!"); whichway(location[position]); run: next = getcom(mainbuf, sizeof mainbuf, ">-: ", "Please type in something."); for (wordcount = 0; next && wordcount < NWORD - 1; wordcount++) next = getword(next, words[wordcount], -1); parse(); switch (cypher()) { case -1: goto run; case 0: goto start; default: errx(1, "bad return from cypher(): please submit a bug report"); } } bsd-games-2.17/battlestar/command7.c0000664000175000017500000002001607767741711016035 0ustar jsm28jsm28/* $NetBSD: command7.c,v 1.2 2003/08/07 09:37:01 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)com7.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: command7.c,v 1.2 2003/08/07 09:37:01 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" int fight(enemy, strength) int enemy, strength; { int lifeline = 0; int hurt; char auxbuf[LINELENGTH]; char *next; int i; int exhaustion; exhaustion = 0; fighton: ourtime++; snooze -= 5; if (snooze > ourtime) exhaustion = CYCLE / (snooze - ourtime); else { puts("You collapse exhausted, and he pulverizes your skull."); die(); } if (snooze - ourtime < 20) puts("You look tired! I hope you're able to fight."); next = getcom(auxbuf, LINELENGTH, "-: ", 0); for (i = 0; next && i < 10; i++) next = getword(next, words[i], -1); parse(); switch (wordvalue[wordnumber]) { case KILL: case SMITE: if (testbit(inven, TWO_HANDED)) hurt = rnd(70) - 2 * card(injuries, NUMOFINJURIES) - ucard(wear) - exhaustion; else if (testbit(inven, SWORD) || testbit(inven, BROAD)) hurt = rnd(50) % (WEIGHT - carrying) - card(injuries, NUMOFINJURIES) - encumber - exhaustion; else if (testbit(inven, KNIFE) || testbit(inven, MALLET) || testbit(inven, CHAIN) || testbit(inven, MACE) || testbit(inven, HALBERD)) hurt = rnd(15) - card(injuries, NUMOFINJURIES) - exhaustion; else hurt = rnd(7) - encumber; if (hurt < 5) switch (rnd(3)) { case 0: puts("You swung wide and missed."); break; case 1: puts("He checked your blow. CLASH! CLANG!"); break; case 2: puts("His filthy tunic hangs by one less thread."); break; } else if (hurt < 10) { switch (rnd(3)) { case 0: puts("He's bleeding."); break; case 1: puts("A trickle of blood runs down his face."); break; case 2: puts("A huge purple bruise is forming on the side of his face."); break; } lifeline++; } else if (hurt < 20) { switch (rnd(3)) { case 0: puts("He staggers back quavering."); break; case 1: puts("He jumps back with his hand over the wound."); break; case 2: puts("His shirt falls open with a swath across the chest."); break; } lifeline += 5; } else if (hurt < 30) { switch (rnd(3)) { case 0: printf("A bloody gash opens up on his %s side.\n", (rnd(2) ? "left" : "right")); break; case 1: puts("The steel bites home and scrapes along his ribs."); break; case 2: puts("You pierce him, and his breath hisses through clenched teeth."); break; } lifeline += 10; } else if (hurt < 40) { switch (rnd(3)) { case 0: puts("You smite him to the ground."); if (strength - lifeline > 20) puts("But in a flurry of steel he regains his feet!"); break; case 1: puts("The force of your blow sends him to his knees."); puts("His arm swings lifeless at his side."); break; case 2: puts("Clutching his blood drenched shirt, he collapses stunned."); break; } lifeline += 20; } else { switch (rnd(3)) { case 0: puts("His ribs crack under your powerful swing, flooding his lungs with blood."); break; case 1: puts("You shatter his upheld arm in a spray of blood. The blade continues deep"); puts("into his back, severing the spinal cord."); lifeline += 25; break; case 2: puts("With a mighty lunge the steel slides in, and gasping, he falls to the ground."); lifeline += 25; break; } lifeline += 30; } break; case BACK: if (enemy == DARK && lifeline > strength * 0.33) { puts("He throws you back against the rock and pummels your face."); if (testbit(inven, AMULET) || testbit(wear, AMULET)) { printf("Lifting the amulet from you, "); if (testbit(inven, MEDALION) || testbit(wear, MEDALION)) { puts("his power grows and the walls of\nthe earth tremble."); puts("When he touches the medallion, your chest explodes and the foundations of the\nearth collapse."); puts("The planet is consumed by darkness."); die(); } if (testbit(inven, AMULET)) { clearbit(inven, AMULET); carrying -= objwt[AMULET]; encumber -= objcumber[AMULET]; } else clearbit(wear, AMULET); puts("he flees down the dark caverns."); clearbit(location[position].objects, DARK); injuries[SKULL] = 1; followfight = ourtime; return (0); } else { puts("I'm afraid you have been killed."); die(); } } else { puts("You escape stunned and disoriented from the fight."); puts("A victorious bellow echoes from the battlescene."); if (back && position != back) moveplayer(back, BACK); else if (ahead && position != ahead) moveplayer(ahead, AHEAD); else if (left && position != left) moveplayer(left, LEFT); else if (right && position != right) moveplayer(right, RIGHT); else moveplayer(location[position].down, AHEAD); return (0); } case SHOOT: if (testbit(inven, LASER)) { if (strength - lifeline <= 50) { printf("The %s took a direct hit!\n", objsht[enemy]); lifeline += 50; } else { puts("With his bare hand he deflects the laser blast and whips the pistol from you!"); clearbit(inven, LASER); setbit(location[position].objects, LASER); carrying -= objwt[LASER]; encumber -= objcumber[LASER]; } } else puts("Unfortunately, you don't have a blaster handy."); break; case DROP: case DRAW: cypher(); ourtime--; break; default: puts("You don't have a chance; he is too quick."); break; } if (lifeline >= strength) { printf("You have killed the %s.\n", objsht[enemy]); if (enemy == ELF || enemy == DARK) puts("A watery black smoke consumes his body and then vanishes with a peal of thunder!"); clearbit(location[position].objects, enemy); power += 2; notes[JINXED]++; return (0); } puts("He attacks..."); /* Some embellishments. */ hurt = rnd(NUMOFINJURIES) - (testbit(inven, SHIELD) != 0) - (testbit(wear, MAIL) != 0) - (testbit(wear, HELM) != 0); hurt += (testbit(wear, AMULET) != 0) + (testbit(wear, MEDALION) != 0) + (testbit(wear, TALISMAN) != 0); hurt = hurt < 0 ? 0 : hurt; hurt = hurt >= NUMOFINJURIES ? NUMOFINJURIES - 1 : hurt; if (!injuries[hurt]) { injuries[hurt] = 1; printf("I'm afraid you have suffered %s.\n", ouch[hurt]); } else puts("You emerge unscathed."); if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]) { puts("I'm afraid you have suffered fatal injuries."); die(); } goto fighton; } bsd-games-2.17/battlestar/nightfile.c0000664000175000017500000016621107767741711016311 0ustar jsm28jsm28/* $NetBSD: nightfile.c,v 1.12 2003/08/07 09:37:02 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)nightfile.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: nightfile.c,v 1.12 2003/08/07 09:37:02 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" struct room nightfile[] = { {0, {0}, 0, {0} }, /* 1 */ {"You are in the main hangar.", {5, 2, 9, 3, 3, 1, 0, 0}, "This is a huge bay where many fighters and cargo craft lie. Alarms are \n\ sounding and fighter pilots are running to their ships. Above is a gallery\n\ overlooking the bay. The scream of turbo engines is coming from +. The rest\n\ of the hangar is +. There is an exit +.*\n", {0} }, /* 2 */ {"This is the landing bay.", {1, 0, 10, 0, 0, 0, 0, 0}, "Ships are landing here, some heavily damaged. Enemy fighters continually\n\ strafe this vulnerable port. The main hangar is +. *\n\ There is an exit +.*\n", {0} }, /* 3 */ {"You are in the gallery.", {4, 0, 0, 0, 0, 0, 1, 0}, "From here a view of the entire landing bay reveals that our battlestar\n\ is near destruction. Fires are spreading out of control and laser blasts\n\ lick at the shadows. The control room is +. ***\n", {0} }, /* 4 */ {"You are in the control room.", {0, 3, 0, 0, 0, 0, 5, 0}, "Several frantic technicians are flipping switches wildly but otherwise\n\ this room seems fairly deserted. A weapons locker has been left open.\n\ A staircase leads down. * There is a way -. ** \n", {0} }, /* 5 */ {"This is the launch room.", {6, 1, 7, 0, 4, 1, 0, 0}, "From the launch tubes here fighters blast off into space. Only one is left,\n\ and it is guarded by two fierce men. A staircase leads up from here.\n\ There is a cluttered workbench +. From the main hangar come sounds of great\n\ explosions. The main hangar is +. The viper launch tubes are -.*\n", {0} }, /* 6 */ {"You are at the workbench.", {0, 5, 7, 0, 0, 0, 0, 0}, "Strange and unwieldy tools are arranged here including a lunch box \n\ and pneumatic wrenches and turbo sprocket rockets.*\n\ The launch room is +. The remaining viper is +.*\n", {0} }, /* 7 */ {"You are in the viper launch tube.", {0, 5, 0, 5, 32, 0, 0, 0}, "The two guards are eyeing you warily! ****\n", {0} }, /* 8 */ {"This is a walk in closet.", {22, 0, 0, 0, 0, 0, 0, 0}, "A wardrobe of immense magnitude greets the eye. Furs and robes of kings\n\ hang on rack after rack. Silken gowns, capes woven with spun gold, and \n\ delicate synthetic fabrics are stowed here. The bedroom is +.***\n", {0} }, /* 9 */ {"You are in a wide hallway leading to the main hangar.", {0, 0, 11, 1, 0, 0, 0, 0}, "The walls and ceiling here have been blasted through in several places.\n\ It looks as if quite a battle has been fought for possession of the landing bay\n\ Gaping corpses litter the floor.** The hallway continues +.\n\ The main hangar is +.\n", {0} }, /* 10 */ {"You are in a wide hallway leading to the landing bay.", {0, 0, 12, 2, 0, 0, 0, 0}, "Most of the men and supplies needed in the main hangar come through this\n\ corridor, but the wounded are forced to use it too. It very dank and\n\ crowded here, and the floor is slippery with blood.**\n\ The hallway continues -. The landing bay is +.\n", {0} }, /* 11 */ {"The hallway is very congested with rubble here.", {0, 0, 0, 9, 13, 1, 0, 0}, "It is too choked with broken steel girders and other debris to continue\n\ on much farther. Above, the ceiling has caved in and it is possible to \n\ climb up. There is not much chance to go -, -, or -.\n\ But the hallway seems clearer +.\n", {0} }, /* 12 */ {"A wide hallway and a more narrow walkway meet here.", {14, 15, 0, 10, 0, 0, 0, 0}, "The intersection is crowded with the many wounded who have come up\n\ the wide hallway and continued +. The walkway is less crowded +.\n\ The wide hallway goes *-.\n", {0} }, /* 13 */ {"You are in what was once an elegant stateroom.", {16, 0, 0, 0, 0, 0, 11, 0}, "Whoever lived in this stateroom, he and his female companion\n\ were mercilessly slain in their sleep. Clothes, trinkets and personal\n\ belongings are scattered all across the floor. Through a hole in the\n\ collapsed floor I can see a hallway below. A door is +.***\n", {0} }, /* 14 */ {"You're at the entrance to the sick bay.", {17, 12, 18, 0, 0, 0, 0, 0}, "The wounded are entering the sick bay in loudly moaning files.\n\ The walkway continues - and +. A doctor is motioning for you to \n\ come to the -. *\n", {0} }, /* 15 */ {"You're in the walkway.", {12, 19, 0, 0, 0, 0, 0, 0}, "Most of the men and supplies were coming from the armory. The walkway\n\ continues -. The armory is +.**\n", {0} }, /* 16 */ {"These are the executive suites of the battlestar.", {20, 13, 21, 22, 23, 1, 24, 0}, "Luxurious staterooms carpeted with crushed velvet and adorned with beaten\n\ gold open onto this parlor. A wide staircase with ivory banisters leads\n\ up or down. This parlor leads into a hallway +. The bridal suite is\n\ +. Other rooms lie - and +.\n", {0} }, /* 17 */ {"You're in a long dimly lit hallway.", {0, 14, 25, 0, 0, 0, 0, 0}, "This part of the walkway is deserted. There is a dead end +. The\n\ entrance to the sickbay is +. The walkway turns sharply -.*\n", {0} }, /* 18 */ {"This is the sick bay.", {0, 0, 0, 14, 0, 0, 0, 0}, "Sinister nurses with long needles and pitiful aim probe the depths of suffering\n\ here. Only the mortally wounded receive medical attention on a battlestar,\n\ but afterwards they are thrown into the incinerators along with the rest.**\n\ Nothing but death and suffering +. The walkway is +.\n", {0} }, /* 19 */ {"You're in the armory.", {15, 26, 0, 0, 0, 0, 0, 0}, "An armed guard is stationed here 365 sectars a yarn to protect the magazine.\n\ The walkway is +. The magazine is +.**\n", {0} }, /* 20 */ {"The hallway ends here at the presidential suite.", {27, 16, 0, 0, 0, 0, 0, 0}, "The door to this suite is made from solid magnesium, and the entryway is\n\ inlaid with diamonds and fire opals. The door is ajar +. The hallway\n\ goes -.**\n", {0} }, /* 21 */ {"This is the maid's utility room.", {0, 0, 0, 16, 0, 0, 0, 0}, "What a gruesome sight! The maid has been brutally drowned in a bucket of\n\ Pine Sol and repeatedly stabbed in the back with a knife.***\n\ The hallway is +.\n", {0} }, /* 22 */ {"This is a luxurious stateroom.", {0, 8, 16, 0, 0, 0, 0, 0}, "The floor is carpeted with a soft animal fur and the great wooden furniture\n\ is inlaid with strips of platinum and gold. Electronic equipment built\n\ into the walls and ceiling is flashing wildly. The floor shudders and\n\ the sounds of dull explosions rumble though the room. From a window in\n\ the wall + comes a view of darkest space. There is a small adjoining\n\ room +, and a doorway +.*\n", {0} }, /* 23 */ {"You are at the entrance to the dining hall.", {0, 0, 28, 0, 0, 0, 16, 0}, "A wide staircase with ebony banisters leads down here.**\n\ The dining hall is -.*\n", {0} }, /* 24 */ {"This was once the first class lounge.", {0, 0, 29, 0, 16, 1, 0, 0}, "There is much rubble and destruction here that was not apparent elsewhere.\n\ The walls and ceilings have broken in in some places. A staircase with\n\ red coral banisters leads up. It is impossible to go - or -.\n\ It seems a little clearer +.*\n", {0} }, /* 25 */ {"You are in a narrow stairwell.", {0, 17, 0, 0, 30, 1, 0, 0}, "These dusty and decrepit stairs lead up. There is no way -. The\n\ hallway turns sharply -.**\n", {0} }, /* 26 */ {"You are in the magazine.", {19, 0, 0, 0, 0, 0, 0, 0}, "Rows and rows of neatly stacked ammunition for laser pistols and grenade\n\ launchers are here. The armory is +.***\n", {0} }, /* 27 */ {"You're in the presidential suite.", {0, 20, 0, 0, 0, 0, 0, 0}, "Apparently the president has been assassinated. A scorched figure lies\n\ face downward on the carpet clutching his chest.*\n\ The hallway leads -.**\n", {0} }, /* 28 */ {"You are in the dining hall.", {0, 30, 31, 23, 0, 0, 0, 0}, "This was the scene of a mass suicide. Hundreds of ambassadors and assorted\n\ dignitaries sit slumped over their breakfast cereal. I suppose the news\n\ of the cylon attack killed them. There is a strange chill in this room. I\n\ would not linger here. * The kitchen is +. Entrances + and +.\n", {0} }, /* 29 */ {"The debris is very thick here.", {0, 11, 0, 24, 0, 0, 0, 0}, "Broken furniture, fallen girders, and other rubble block the way.\n\ There is not much chance to continue -, -, or -.\n\ It would be best to go -.\n", {0} }, /* 30 */ {"You are in the kitchen.", {28, 0, 0, 0, 0, 0, 0, 0}, "This room is full of shining stainless steel and burnished bronze cookware. An \n\ assortment of tropical fruits and vegetables as well as fine meats and cheeses \n\ lies on a sterling platter. The chef, unfortunately, has been skewered like a \n\ side of beef. The dining room is +. ** There is a locked door +.\n", {0} }, /* 31 */ {"You are in an arched entry leading to the dining room.", {0, 0, 0, 28, 0, 0, 0, 0}, "The door leading out is bolted shut from the outside and is very strong.***\n\ The dining room is +.\n", {0} }, /* 32 */ {"You are in space.", {33, 34, 35, 36, 37, 1, 33, 1}, "****\n", {0} }, /* 33 */ {"You are in space.", {38, 32, 39, 40, 41, 1, 42, 1}, "****\n", {0} }, /* 34 */ {"You are in space.", {32, 44, 45, 46, 47, 1, 48, 1}, "****\n", {0} }, /* 35 */ {"You are in space.", {40, 45, 49, 32, 50, 1, 51, 1}, "****\n", {0} }, /* 36 */ {"You are in space.", {41, 46, 32, 52, 53, 1, 54, 1}, "****\n", {0} }, /* 37 */ {"You are in space.", {42, 47, 50, 53, 55, 1, 32, 1}, "****\n", {0} }, /* 38 */ {"You are in space.", {43, 48, 51, 54, 32, 1, 56, 1}, "****\n", {0} }, /* 39 */ {"You are in space.", {57, 33, 40, 41, 42, 1, 43, 1}, "****\n", {0} }, /* 40 */ {"You are in space.", {39, 35, 57, 33, 58, 1, 59, 1}, "****\n", {0} }, /* 41 */ {"You are in space.", {39, 36, 33, 59, 60, 1, 61, 1}, "****\n", {0} }, /* 42 */ {"You are in space.", {39, 37, 58, 60, 62, 1, 33, 1}, "****\n", {0} }, /* 43 */ {"You are in space.", {39, 38, 59, 61, 33, 1, 63, 1}, "****\n", {0} }, /* 44 */ {"You are in space.", {34, 64, 45, 46, 47, 1, 48, 1}, "****\n", {0} }, /* 45 */ {"You are in space.", {35, 44, 49, 34, 50, 1, 51, 1}, "****\n", {0} }, /* 46 */ {"You are in space.", {36, 44, 34, 52, 53, 1, 54, 1}, "****\n", {0} }, /* 47 */ {"You are in space.", {37, 44, 50, 53, 55, 1, 34, 1}, "****\n", {0} }, /* 48 */ {"You are in space.", {38, 44, 51, 54, 34, 1, 56, 1}, "****\n", {0} }, /* 49 */ {"You are in space.", {49, 49, 52, 35, 49, 1, 49, 1}, "****\n", {0} }, /* 50 */ {"You are in space.", {58, 47, 49, 37, 55, 1, 35, 1}, "****\n", {0} }, /* 51 */ {"You are in space.", {59, 48, 49, 38, 35, 1, 56, 1}, "****\n", {0} }, /* 52 */ {"You are in space.", {52, 52, 36, 49, 52, 1, 52, 1}, "****\n", {0} }, /* 53 */ {"You are in space.", {60, 46, 37, 52, 55, 1, 36, 1}, "****\n", {0} }, /* 54 */ {"You are in space.", {61, 48, 38, 52, 36, 1, 56, 1}, "****\n", {0} }, /* 55 */ {"You are in space.", {62, 55, 55, 55, 56, 1, 37, 1}, "****\n", {0} }, /* 56 */ {"You are in space.", {56, 56, 56, 56, 38, 1, 55, 1}, "****\n", {0} }, /* 57 */ {"You are in space.", {65, 39, 57, 57, 57, 1, 57, 1}, "****\n", {0} }, /* 58 */ {"You are in space.", {39, 50, 49, 42, 62, 1, 40, 1}, "****\n", {0} }, /* 59 */ {"You are in space.", {39, 51, 49, 43, 40, 1, 63, 1}, "****\n", {0} }, /* 60 */ {"You are in space.", {39, 53, 43, 59, 62, 1, 41, 1}, "****\n", {0} }, /* 61 */ {"You are in space.", {39, 54, 43, 59, 41, 1, 56, 1}, "****\n", {0} }, /* 62 */ {"You are in space.", {39, 55, 62, 62, 56, 1, 42, 1}, "****\n", {0} }, /* 63 */ {"You are in space.", {39, 56, 35, 36, 43, 1, 55, 1}, "****\n", {0} }, /* 64 */ {"You are in space.", {44, 66, 66, 66, 66, 1, 66, 1}, "****\n", {0} }, /* 65 */ {"You are in space.", {67, 57, 67, 67, 67, 1, 67, 1}, "****\n", {0} }, /* 66 */ {"You are in space.", {64, 68, 68, 68, 68, 1, 68, 1}, "****\n", {0} }, /* 67 */ {"You are orbiting a small blue planet.", {67, 67, 67, 67, 65, 1, 69, 1}, "****\n", {0} }, /* 68 */ {"You are orbiting a tropical planet.", {68, 68, 68, 68, 66, 1, 70, 1}, "****\n", {0} }, /* 69 */ {"You are flying through a dense fog.", {69, 69, 69, 69, 69, 1, 69, 1}, "A cold grey sea of mist is swirling around the windshield and water droplets\n\ are spewing from the wingtips. Ominous shadows loom in the darkness and it\n\ feels as if a trap is closing around us. I have lost all sense of direction.\n\ ****\n", {0} }, /* 70 */ {"You are approaching an island.", {71, 72, 73, 74, 68, 1, 0, 1}, "Feather palms outlined by mellow moonlight and a silvery black ocean line\n\ the perimeter of the island. Mighty mountains of emerald and amethyst rise\n\ like jagged teeth from black gums. The land rises sharply +. The shore\n\ line stretches on *+.*\n", {0} }, /* 71 */ {"You are flying over a mountainous region.", {75, 73, 76, 77, 68, 1, 0, 1}, "Below is a shadow=filled canyon with looming spires and pinnacles and\n\ luminous waterfalls plummeting down beyond sight. **The ocean is +.*\n", {0} }, /* 72 */ {"You are flying over the ocean.", {74, 78, 78, 78, 68, 1, 0, 1}, "You bank over the water and your wingtips dip low to the green waves. The\n\ sea is very shallow here and the white coral beds beneath us teem with \n\ shadowy fish.****\n", {0} }, /* 73 */ {"You are flying over the beach.", {71, 72, 79, 74, 68, 1, 80, 1}, "A warm gentle surf caresses the beach here. The land rises\n\ sharply +.* The beach is lost in low cliffs +.*\n", {0} }, /* 74 */ {"You are flying over a large lagoon.", {81, 72, 73, 82, 68, 1, 0, 1}, "The water's brink winds tortuously inland. There are some lights +.***\n", {0} }, /* 75 */ {"You are flying over a gently sloping plane.", {83, 71, 84, 85, 68, 1, 0, 1}, "The ground appears to be choked with vegetation.* The terrain is more\n\ rugged +.**\n", {0} }, /* 76 */ {"You are flying through a gorge.", {0, 0, 86, 71, 68, 1, 102, 1}, "This is a narrow, steep sided canyon lined with plants. The stars above\n\ glisten through the over hanging trees. The gorge leads to the\n\ sea** +, and to a tumultuous origin +.\n", {0} }, /* 77 */ {"You are flying over a plantation.", {85, 81, 71, 88, 68, 1, 89, 1}, "It might be possible to land here, but not in the dark.* There are some lights\n\ + and *+.\n", {0} }, /* 78 */ {"You are over the ocean.", {72, 78, 79, 74, 68, 1, 0, 1}, "The deep green swells foam and roll into the shore **+*.\n", {0} }, /* 79 */ {"You are flying along the coast.", {86, 72, 90, 73, 68, 1, 91, 1}, "The coastline here is very rocky. The surf in some places is violent\n\ and explodes in a shower of sparkling, moonlit spray. ****\n", {0} }, /* 80 */ {"This is a beautiful coral beach.", {106, 0, 107, 108, 73, 0, 0, 0}, "Fine silver sand kissed lightly by warm tropical waters and illuminated\n\ by a huge tropical moon stretches at least 30 meters inland.\n\ Gently swaying palm trees are +.***\n", {0} }, /* 81 */ {"You are flying over a small fishing village.", {77, 74, 71, 82, 68, 1, 92, 1}, "A few thatched huts lit with torches and bonfires line a road below.\n\ The road continues on ***+.\n", {0} }, /* 82 */ {"You are flying over a clearing.", {88, 72, 74, 87, 68, 1, 93, 1}, "There is a dock here (big enough for a seaplane) leading to a clearing.\n\ The still waters of the lagoon reflects our orange turbo thrusters.****\n", {0} }, /* 83 */ {"You are flying over the shore.", {94, 75, 95, 96, 68, 1, 0, 1}, "Rocky lava flows have overtaken the beach here.****\n", {0} }, /* 84 */ {"You are flying in a wide valley.", {95, 97, 86, 75, 68, 1, 98, 1}, "This is a shallow valley yet the floor is obscured by a thick mist.\n\ The valley opens into blackness +. The mist grows thicker +.**\n", {0} }, /* 85 */ {"You are flying near the shore.", {96, 77, 75, 99, 68, 1, 0, 1}, "Very tall trees growing in neatly planted rows march off from the \n\ water here towards the hills and down to the flat lands *+.**\n", {0} }, /* 86 */ {"You are flying around the very tip of the island.", {95, 79, 90, 84, 68, 1, 0, 1}, "Sheer cliffs rise several hundred feet to a tree covered summit. Far below,\n\ the grey sea gnaws voraciously at the roots of these cliffs. The island bends\n\ around +** and +.\n", {0} }, /* 87 */ {"You are flying along the coastline.", {99, 82, 88, 100, 68, 1, 101, 1}, "This is a narrow strip of sand lined with very few trees. The stars above\n\ flicker through wisps of clouds. The beach continues on -.* There\n\ are some lights +.*\n", {0} }, /* 88 */ {"You are flying over several cottages and buildings", {99, 82, 77, 87, 68, 1, 103, 1}, "Directly below is small ornate house lit up with spot lights and decorative\n\ bulbs. A bell tower and a spurting fountain are nearby. Small dirt roads go\n\ + and +.**\n", {0} }, /* 89 */ {"You are in a field of sugar cane.", {109, 110, 111, 112, 77, 0, 0, 0}, "These strong, thick canes give little shelter but many cuts and scrapes.\n\ There are some large trees ***+.\n", {0} }, /* 90 */ {"You are flying over the ocean.", {95, 78, 90, 86, 68, 1, 0, 1}, "The water is a placid ebony.****\n", {0} }, /* 91 */ {"You are on the coast road.", {113, 114, 115, 116, 79, 0, 0, 0}, "The road winds close to the shore here. The trees on either side press close\n\ in the darkness and seem to be watching us.** The road continues -\n\ and -.\n", {0} }, /* 92 */ {"You are on the main street of the village.", {117, 118, 119, 120, 81, 0, 0, 0}, "The natives are having a festive luau here. Beautiful dancers gyrate in the\n\ torchlight to the rhythm of wooden drums. A suckling pig is sizzling in a\n\ bed of coals and ti leaves are spread with poi and tropical fruits. Several\n\ natives have come over to you and want you to join in the festivities.\n\ There is a light burning in a bungalow +.***\n", {0} }, /* 93 */ {"You are at the sea plane dock.", {121, 122, 123, 124, 82, 0, 0, 0}, "The clearing is deserted. The grass is wet with the evening dew +.*\n\ There is something set up +.*\n", {0} }, /* 94 */ {"You are flying over the ocean.", {94, 83, 95, 96, 68, 1, 0, 1}, "The black waves surge off shore here. The ocean becomes much calmer +.***\n", {0} }, /* 95 */ {"You are flying along the coast.", {94, 84, 86, 83, 68, 1, 0, 1}, "The land is very low here with a river running into the sea +. There\n\ is a wide valley opening up +, but a strange mist is flowing out of it.\n\ The very tip of the island is +.*\n", {0} }, /* 96 */ {"You are flying along the coast.", {94, 85, 83, 99, 68, 1, 0, 1}, "The coast here is cluttered with rocky outcroppings.****\n", {0} }, /* 97 */ {"You are lost in a sea of fog.", {97, 104, 97, 97, 97, 1, 0, 1}, "What have you gotten us into?\n\ I can't see a thing! ****\n", {0} }, /* 98 */ {"You are on a gravel wash.", {125, 126, 127, 128, 84, 0, 0, 0}, "It is very dark here. A cool breeze is blowing from +. No moonlight can\n\ reach below a thick canopy of fog above. The sound of cascading water is\n\ coming from +.**\n", {0} }, /* 99 */ {"You are flying over a wide beach.", {96, 88, 85, 87, 68, 1, 105, 1}, "There are some lighted buildings *+. Some trees are growing +.*\n", {0} }, /* 100 */ {"You are flying over the ocean.", {100, 100, 87, 100, 68, 1, 0, 1}, "The black waves surge and splash against the rocky shore.****\n", {0} }, /* 101 */ {"You are on a narrow strip of sand.", {129, 130, 131, 0, 87, 0, 0, 0}, "Rather coarse sand makes this beach very steep and only a few meters wide.\n\ A fresh ocean breeze is rustling the ferns **+.*\n", {0} }, /* 102 */ {"This is Fern Canyon.", {0, 0, 132, 133, 76, 0, 0, 0}, "Delicate waving ferns flourish here, suckled by warm water dripping from \n\ every fissure and crevice in the solid rock walls. The stars above sparkle\n\ through a thin mist. The canyon winds **-, and -.\n", {0} }, /* 103 */ {"This is the front lawn.", {134, 135, 136, 137, 88, 0, 0, 0}, "There is a small fountain lighted with green and yellow bulbs here where\n\ the driveway meets the lawn. Across the driveway, +, is an ornate white\n\ house lit with gas lamps. A bell tower here is awash in pale blue.* There\n\ is a road + which turns into the driveway.*\n", {0} }, /* 104 */ {"You have just crossed the crest of a mountain.", {97, 79, 86, 71, 68, 1, 0, 1}, "The fog vanished mysteriously as we flew over the crest.*\n\ Far + I can see the ocean sparkling in the moonlight.**\n", {0} }, /* 105 */ {"You are on a sandy beach.", {138, 139, 140, 0, 99, 0, 0, 0}, "Fine coral sand, a fresh sea breeze, and dramatic surf add to this beach's\n\ appeal.** Stone steps lead to a lighted path in the gardens +.*\n", {0} }, /* 106 */ {"You are among palm trees near the shore.", {141, 80, 142, 143, 73, 0, 0, 0}, "Arching coconut palms laden with fruit provide a canopy for the glistening\n\ white sand and sparse, dew covered grasses growing here. The forest grows\n\ denser +. Crickets are chirping loudly here. The ocean is +.**\n", {0} }, /* 107 */ {"You are walking along the beach.", {144, 0, 145, 80, 73, 0, 0, 0}, "The warm tropical waters nuzzle your ankles as you walk. Above is a gorgeous\n\ starscape. The battlestar must be up there somewhere. The slope of the sand\n\ is so gentle that the surf only slides up the sand.** There are some rocks\n\ +.*\n", {0} }, /* 108 */ {"You are walking along the beach.", {146, 0, 80, 147, 73, 0, 0, 0}, "The tide is out very far tonight, and it is possible to explore hidden rocks\n\ and caves not ordinarily accessible. Rich beds of seaweed have been exposed\n\ to the cool night air.****\n", {0} }, /* 109 */ {"You are in a papaya grove.", {148, 89, 149, 150, 77, 0, 0, 0}, "Slender trees with their large seven lobed leaves bulge with succulent fruit.\n\ There are some tall trees +.***\n", {0} }, /* 110 */ {"You are in a field of pineapple.", {89, 151, 152, 153, 77, 0, 0, 0}, "The sharp dagger like pineapple leaves can pierce the flesh and hold fast\n\ a skewered victim with tiny barbs.* The field ends +.**\n", {0} }, /* 111 */ {"You are in a field of kiwi plants.", {149, 154, 155, 89, 77, 0, 0, 0}, "Round hairy fruit hang from staked vines here. There are some trees +\n\ and +. The field ends in a road +.*\n", {0} }, /* 112 */ {"You are in a large grove of coconuts.", {150, 153, 89, 156, 77, 0, 0, 0}, "These trees are much taller than any growing near the shore and the shadows\n\ are also deeper. It's hard to keep my sense of direction.****\n", {0} }, /* 113 */ {"You are in the woods.", {157, 91, 158, 116, 79, 0, 0, 0}, "Tropical undergrowth makes the going rough here. Sword ferns give no strong\n\ foot hold and the dangling vines would gladly throttle one. The darkness is\n\ so intense here that we stand in utter blackness.****\n", {0} }, /* 114 */ {"You are at the shore.", {91, 0, 159, 145, 79, 0, 160, 0}, "The low minus tide tonight might make it possible to climb down to a\n\ small cave entrance below. Large rocks would usually churn the waves\n\ asunder.*** The beach goes -.\n", {0} }, /* 115 */ {"You are on the coast road.", {158, 161, 162, 91, 79, 0, 0, 0}, "The road is beginning to turn slightly -. I can hear the surf +. The road\n\ continues into the dark forest +.*\n", {0} }, /* 116 */ {"The road winds deeper into the trees.", {163, 142, 91, 164, 79, 0, 0, 0}, "Only narrow moonbeams filter through the dense foliage above. The moist rich\n\ earth has nurtured a myriad of slugs, snakes, and spiders to grow here. The\n\ road continues - and *- into the shadows.*\n", {0} }, /* 117 */ {"This is the front porch of the bungalow.", {165, 92, 0, 0, 81, 0, 0, 0}, "The veranda is lit by a small yellow bug light. The door leads -.\n\ The stone walk down to the luau is lined with burning torches +. That\n\ roast pig smells good.**\n", {0} }, /* 118 */ {"You are on a path leading to the lagoon.", {92, 166, 167, 168, 81, 0, 0, 0}, "This path winds through the underbrush and towards the lagoon *+. The\n\ broad faced moon peeps though the branches above. The sound of drums echos\n\ in the woods.**\n", {0} }, /* 119 */ {"This is a dirt road.", {169, 118, 170, 92, 81, 0, 0, 0}, "**The road continues on - here for some distance. A bonfire and party light\n\ up the night sky +.\n", {0} }, /* 120 */ {"You are on a dirt road.", {171, 118, 92, 172, 81, 0, 0, 0}, "**There is a village +. A huge bonfire licks at the trees, and a celebration\n\ of some sort is going on there. The smell of luscious cooking is tantalizing\n\ my flared nostrils. The road continues +.\n", {0} }, /* 121 */ {"You are on a dirt road.", {173, 93, 174, 175, 82, 0, 0, 0}, "This is a wide grassy clearing bedewed with droplets of evening mist. The\n\ trees alongside the road moan and whisper as we pass. They seem annoyed at\n\ our presence. **The road continues - and -.\n", {0} }, /* 122 */ {"You are at the seaplane dock.", {93, 0, 176, 177, 82, 0, 0, 0}, "Not a living thing stirs the calm surface of the lagoon. The wooden planks\n\ creak unnaturally as we tread on them. The dock reaches a clearing +.\n\ A dark trail leads around the lagoon **+.\n", {0} }, /* 123 */ {"There are some tables on the lawn here.", {121, 122, 123, 93, 82, 0, 0, 0}, "Some tables are strewn on the wet lawn.****\n", {0} }, /* 124 */ {"You are nosing around in the bushes.", {124, 124, 93, 124, 82, 0, 0, 0}, "There is little here but some old beer cans. It is damp and dirty in here.\n\ I think I stepped in something unpleasant. It would be best to go **-.*\n", {0} }, /* 125 */ {"You are walking in a dry stream bed.", {178, 98, 179, 0, 84, 0, 0, 0}, "The large cobblestones are difficult to walk on. No starlight reaches\n\ below a black canopy of fog seemingly engulfing the whole island. A dirt\n\ path along the wash is **+. The high bank is impossible to climb +.\n", {0} }, /* 126 */ {"You are at the thermal pools.", {98, 0, 180, 181, 84, 0, 0, 0}, "Odd spluttering and belching water splashes up around the rocks here.\n\ A spectacular waterfall nearby tumbles down as a river of effervescent\n\ bubbles. The air is quite warm and a cave entrance ***+ spews steam.\n", {0} }, /* 127 */ {"You are in the woods.", {127, 180, 182, 98, 84, 0, 0, 0}, "It is pitch black in the forest here and my pant leg is caught on something.\n\ There may be poison oak here. What was that? A lantern just flickered by in\n\ the dark! The sound of rushing water is coming from *+.**\n", {0} }, /* 128 */ {"You are on a dirt trail.", {179, 181, 98, 0, 84, 0, 0, 0}, "The trail seems to start here and head towards the forest +.** High,\n\ dark cliffs border the trail +. Some crickets are chirping\n\ noisily.\n", {0} }, /* 129 */ {"You are walking along the beach.", {183, 101, 184, 0, 87, 0, 0, 0}, "The surf is rather tame tonight. The beach continues + and +.**\n", {0} }, /* 130 */ {"You are walking along the beach.", {101, 185, 186, 0, 87, 0, 0, 0}, "This is not a very nice beach. The coarse sand hurts my feet.****\n", {0} }, /* 131 */ {"You are walking through some ferns.", {184, 186, 187, 101, 87, 0, 0, 0}, "This is a wide field growing only ferns and small shrubs.** In the dark\n\ it would be all to easy to stumble into a venomous snake. The ocean is\n\ *+.\n", {0} }, /* 132 */ {"You are in a narrow canyon.", {0, 0, 188, 102, 76, 0, 0, 0}, "The steep sides here squeeze a little freshet through a gauntlet like\n\ series of riffles and pools. The cool mountain air is refreshing.****\n", {0} }, /* 133 */ {"The canyon is much wider here.", {0, 0, 102, 189, 76, 0, 0, 0}, "The sheer rock walls rise 10 meters into darkness. A slender waterfall\n\ careens away from the face of the rock high above and showers the gravel\n\ floor with sparkling raindrops.** The canyon continues -\n\ and -.\n", {0} }, /* 134 */ {"You are on the front porch of the cottage.", {190, 103, 0, 0, 0, 0, 0, 0}, "The veranda is deserted. A table and chair are the only things on the porch.\n\ Inside the house is a parlor lighted with an elegant chandelier. The door\n\ leads -. The lawn and fountain are +.**\n", {0} }, /* 135 */ {"You are in a palm grove.", {103, 191, 192, 105, 88, 0, 0, 0}, "Crickets are chirping in the cool night air.****\n", {0} }, /* 136 */ {"You are on a dirt road.", {193, 192, 245, 103, 88, 0, 0, 0}, "There are many bright lights +. The road cleaves the darkness +.\n\ A small dirt road goes -, and a driveway peels off +.\n", {0} }, /* 137 */ {"You are in a field of small shrubs.", {184, 186, 103, 187, 88, 0, 0, 0}, "**Pine and other coniferous saplings are growing here. The rich brown\n\ soil is well watered. Across a large lawn +, there is a small cottage lighted\n\ with spot lights and gas lamps. A cool land breeze is blowing.*\n", {0} }, /* 138 */ {"The beach is pretty rocky here.", {194, 105, 195, 0, 96, 0, 0, 0}, "The tide is very low tonight. The beach is nicer *+.**\n", {0} }, /* 139 */ {"The beach is almost 10 meters wide here.", {105, 183, 196, 0, 99, 0, 0, 0}, "The sand has become more coarse and the beach steeper.****\n", {0} }, /* 140 */ {"You are in the gardens.", {195, 196, 197, 105, 99, 0, 0, 0}, "Shadowy expanses of lawn and leaf have been groomed and manicured here.\n\ The night sky is glowing with a full moon.** A lighted path leads -.\n\ Stone steps lead down to the beach +.\n", {0} }, /* 141 */ {"You are on the coast road.", {198, 106, 163, 199, 73, 0, 0, 0}, "The forest is dense on either side. The trees seem to be actually squeezing\n\ together to keep us from passing. A feeling of enmity is in the air.**\n\ The road continues - and -.\n", {0} }, /* 142 */ {"You are in the forest.", {116, 107, 91, 106, 73, 0, 0, 0}, "I suppose there are trees and ferns all around, but it is too dark to see.****\n", {0} }, /* 143 */ {"You are in the forest.", {199, 108, 106, 146, 73, 0, 0, 0}, "There are shadowy trees and ferns all around.****\n", {0} }, /* 144 */ {"You are in a copse.", {142, 107, 145, 80, 0, 0, 0, 0}, "This is a secret hidden thicket only noticeable from the beach. In the\n\ moonlight, I can tell that someone has been digging here recently.****\n", {0} }, /* 145 */ {"You are at the tide pools.", {91, 0, 114, 107, 79, 0, 0, 0}, "These rocks and pools are the home for many sea anemones and crustaceans.\n\ They are exposed because of the low tide. There is a beach ***+.\n", {0} }, /* 146 */ {"You are in the forest.", {199, 108, 143, 0, 73, 0, 0, 0}, "This is a shallow depression sheltered from the wind by a thick growth of \n\ thorny shrubs. It looks like someone is camping here. There is a fire pit\n\ with warm, crackling flames and coals here.* The beach is +.* The thorny\n\ shrubs block the way -.\n", {0} }, /* 147 */ {"You are at the mouth of the lagoon.", {200, 0, 108, 201, 74, 0, 0, 0}, "The beach ends here where the coral reef rises to form a wide lagoon.\n\ A path winds around the lagoon to the -.* The beach continues\n\ on -. Only water lies +.\n", {0} }, /* 148 */ {"You are in a breadfruit grove.", {202, 109, 203, 204, 77, 0, 0, 0}, "The tall trees bend leisurely in the breeze, holding many round breadfruits\n\ close to their large serrated leaves. There are coconut palms +,\n\ *+, and +.\n", {0} }, /* 149 */ {"You are in a grove of mango trees.", {203, 111, 205, 109, 77, 0, 0, 0}, "The trees are not tall enough to obscure the view and the bright moonlight\n\ makes it fairly easy to see.****\n", {0} }, /* 150 */ {"You are in a grove of coconut palms.", {204, 112, 109, 206, 77, 0, 0, 0}, "All I can see around us are trees and ominous shapes darting in and out of the\n\ shadows.****\n", {0} }, /* 151 */ {"You are in a coconut grove.", {110, 207, 208, 209, 77, 0, 0, 0}, "There are countless trees here.****\n", {0} }, /* 152 */ {"You are in a field of pineapple.", {154, 208, 210, 110, 77, 0, 0, 0}, "The sharp leaves are cutting me to ribbons. There is a road **+.*\n", {0} }, /* 153 */ {"You are in a coconut grove.", {112, 209, 110, 211, 77, 0, 0, 0}, "There is a field of something **+.*\n", {0} }, /* 154 */ {"You are on the edge of a kiwi and pineapple field.", {111, 152, 155, 110, 77, 0, 0, 0}, "An irrigation ditch separates the two fields here. There is a road **+.*\n", {0} }, /* 155 */ {"This is a dirt road.", {205, 210, 212, 111, 77, 0, 0, 0}, "The road runs - and - here. It is very dark in the forest.**\n", {0} }, /* 156 */ {"You are in a palm grove.", {206, 211, 112, 213, 77, 0, 0, 0}, "There are trees all around us.****\n", {0} }, /* 157 */ {"You are on the edge of a small clearing.", {157, 113, 157, 157, 79, 0, 0, 0}, "The ground is rather marshy here and the darkness is intense. A swarm of\n\ ravenous mosquitoes has descended upon you and has sent you quaking to your\n\ knees.****\n", {0} }, /* 158 */ {"You are in the woods.", {158, 115, 215, 113, 79, 0, 0, 0}, "You have walked a long way and found only spider webs. ****\n", {0} }, /* 159 */ {"You are walking along the shore.", {115, 0, 214, 114, 86, 0, 0, 0}, "You are now about 10 meters above the surf on a gently rising cliffside.**\n\ The land rises +. There is a beach far +.\n", {0} }, /* 160 */ {"You are just inside the entrance to the sea cave.", {246, 114, 0, 0, 114, 1, 0, 0}, "The sound of water dripping in darkness and the roar of the ocean just outside\n\ create a very unwelcoming atmosphere inside this cave. Only on rare occasions\n\ such as this is it possible to enter the forbidden catacombs... The cave\n\ continues -.***\n", {0} }, /* 161 */ {"You are in a secret nook beside the road.", {115, 159, 162, 91, 79, 0, 0, 0}, "This little thicket is hidden from the road in the shadows of the forest.\n\ From here we have a clear view of any traffic along the road. A great hollow\n\ tree stuffed with something is nearby. The road is +.***\n", {0} }, /* 162 */ {"You are on the coast road.", {215, 214, 0, 115, 86, 0, 0, 0}, "The road turns abruptly - here, wandering deeper into the black forest.***\n", {0} }, /* 163 */ {"You are on a dirt road.", {216, 116, 113, 141, 79, 0, 0, 0}, "We are walking through a tunnel of unfriendly trees and shrubs. The tall\n\ ones bend over the roadway and reach down with their branches to grab us.\n\ Broad leafed plants at the roadside whisper in the darkness. Something\n\ just darted across the road and into the bushes *+. Let's go *-.\n", {0} }, /* 164 */ {"You have discovered a hidden thicket near the road.", {163, 142, 116, 106, 73, 0, 0, 0}, "I would think it best to stay on the road. The forest seems very unfriendly\n\ at night. The road is **+.*\n", {0} }, /* 165 */ {"You are in the living room.", {0, 117, 217, 218, 0, 0, 0, 0}, "A decorative entry with fresh flowers and wall to wall carpeting leads into\n\ the living room here where a couch and two chairs converge with an end table.\n\ *The exit is +.* The bedroom is +.\n", {0} }, /* 166 */ {"You are at the lagoon.", {118, 0, 167, 168, 81, 0, 0, 0}, "A small beach here is deserted except for some fishing nets. It is very\n\ peaceful at the lagoon at night. The sound of native drums is carried on\n\ the night breeze. There are paths leading off into darkness +,\n\ *+, and +.\n", {0} }, /* 167 */ {"You are at the lagoon.", {118, 0, 170, 166, 81, 0, 0, 0}, "The grass near the water is moist with the refreshing evening dew. Far away,\n\ drums reverberate in the forest.** The path continues + and +.\n", {0} }, /* 168 */ {"You are at the lagoon.", {118, 0, 166, 172, 81, 0, 0, 0}, "The path meanders through shadows of tussocks of grass, ferns, and thorny\n\ bushes here and continues on **- and -.\n", {0} }, /* 169 */ {"You are in the woods.", {219, 119, 220, 92, 81, 0, 0, 0}, "There are plenty of ferns and thorny bushes here! Spider webs and probing\n\ branches snare us as we stumble along in the pitch black night.****\n", {0} }, /* 170 */ {"You are on a dirt road.", {220, 167, 199, 119, 74, 0, 0, 0}, "The road winds rather close to a large lagoon here and many sedges and tall\n\ loom in the darkness *+. The road continues - and -.\n", {0} }, /* 171 */ {"You are in the woods beside the road.", {221, 120, 92, 222, 81, 0, 0, 0}, "The forest grows darker +. The road is +.**\n", {0} }, /* 172 */ {"The road crosses the lagoon here.", {222, 0, 120, 174, 81, 0, 0, 0}, "Strange mists rising from the water engulf a rickety old enclosed bridge here.\n\ Spider webs catch our hair as we pass through its rotting timbers. I felt\n\ something drop on my neck. The road delves into the accursed forest\n\ **+ and +.\n", {0} }, /* 173 */ {"You are in a coconut palm grove.", {223, 121, 224, 225, 82, 0, 0, 0}, "The tall palms are planted about 30 feet apart and the starry sky is clearly\n\ visible above. A low growing grass carpets the ground all around. The grove\n\ continues +.***\n", {0} }, /* 174 */ {"You are walking along a dirt road.", {224, 176, 172, 121, 82, 0, 0, 0}, "You are near misty patch of the roadway **+. The road continues -.\n", {0} }, /* 175 */ {"You are on a dirt road.", {225, 177, 121, 226, 82, 0, 0, 0}, "The road turns abruptly - here, splitting a grove of palm trees.* In the\n\ starlight I can also discern that the road continues - toward the lagoon.*\n", {0} }, /* 176 */ {"You are on a trail running around the lagoon.", {172, 0, 0, 122, 82, 0, 0, 0}, "The dark waters brush the trail here and the path crosses an old bridge\n\ +. There is deep water + and +. The trail continues -.\n", {0} }, /* 177 */ {"This is the mouth of the lagoon.", {175, 0, 122, 227, 82, 0, 0, 0}, "The coral reef wraps around a natural bay here to create a wide lagoon which\n\ winds tortuously inland.** A trail goes around the lagoon +.\n\ The beach is -.\n", {0} }, /* 178 */ {"You are in a dry stream bed.", {0, 125, 0, 0, 84, 0, 0, 0}, "The dry wash drains over a tall precipice here into a turbid morass below. The\n\ most noisome stench imaginable is wafting up to defile our nostrils. Above,\n\ the blackness is intense and a strange mist engulfs the island.* Let's go\n\ -.**\n", {0} }, /* 179 */ {"You are on a dirt path along the wash.", {0, 128, 125, 228, 84, 0, 0, 0}, "The trail winds along the gravel wash and delves into the forest ***+.\n", {0} }, /* 180 */ {"The thermal pools flow into a stream here.", {127, 0, 229, 126, 84, 0, 0, 0}, "The gurgling hot waters pour over boulders into a swiftly flowing\n\ stream **+. The pools are +.\n", {0} }, /* 181 */ {"You are at the entrance to a cave.", {128, 230, 126, 0, 84, 0, 0, 0}, "A torch lights the entrance to the cave. Deep inside I can see shadows moving.\n\ A path goes + from here. The entrance is +.**\n", {0} }, /* 182 */ {"You are in the woods.", {182, 229, 182, 127, 84, 0, 0, 0}, "Thorns tangle your every effort to proceed.* The sound of rushing water is\n\ +.**\n", {0} }, /* 183 */ {"You are walking along the beach.", {139, 129, 184, 0, 99, 0, 0, 0}, "Some dunes here progress inland and make it impossible to get very far in that\n\ direction. The beach continues - and -.* The ocean is +.\n", {0} }, /* 184 */ {"You are in the dunes.", {183, 101, 184, 129, 87, 0, 0, 0}, "The endless rolling and pitching sand dunes are enough to make one very queasy!\n\ The sand is cool and the stars are bright at the ocean. The only way I'm going\n\ is ***+.\n", {0} }, /* 185 */ {"This is a lousy beach.", {130, 0, 0, 0, 87, 0, 0, 0}, "Volcanic and viciously sharp bitted grains of sand here bite like cold steel\n\ into my tender feet. I refuse to continue on. Let's get out of here. The\n\ beach is better +.***\n", {0} }, /* 186 */ {"You are in a field of sparse ferns.", {131, 185, 187, 130, 87, 0, 0, 0}, "The lava rock outcroppings here will support few plants. There is more \n\ vegetation +.** The ocean is +.\n", {0} }, /* 187 */ {"You are in the woods.", {131, 131, 137, 131, 87, 0, 0, 0}, "Young trees and tall shrubs grow densely together here.\n\ They grow thicker **+.*\n", {0} }, /* 188 */ {"The canyon is no wider than a foot here.", {0, 0, 0, 132, 0, 0, 0, 0}, "The freshet is gushing through the narrow trough, but the canyon has grown\n\ too narrow to follow it any farther.*** I guess we'll have to go -.\n", {0} }, /* 189 */ {"You are in a narrow part of the canyon.", {0, 0, 133, 232, 76, 0, 0, 0}, "The two sheer sides are no more than a few meters apart here. There is a stone\n\ door in the wall +. The gravelly floor runs with tiny rivulets seeping \n\ from the ground itself.* The canyon continues - and -.\n", {0} }, /* 190 */ {"You are in the drawing room.", {0, 134, 0, 0, 0, 0, 0, 0}, "Exquisitely decorated with plants and antique furniture of superb\n\ craftsmanship, the parlor reflects its owner's impeccable taste. The tropical\n\ night air pours in through open shutters *+. There doesn't seem \n\ to be anybody around. A large immaculate oaken desk is visible in the\n\ study and it even has a old fashioned telephone to complete the decor.**\n", {0} }, /* 191 */ {"You are in a palm grove.", {135, 191, 233, 191, 88, 0, 0, 0}, "Grassy rows of dew covered palms stretch as far as I can see.**\n\ There is a road +.*\n", {0} }, /* 192 */ {"You are on a dirt road.", {136, 233, 234, 135, 88, 0, 0, 0}, "The road winds through a coconut palm grove here. It continues on - \n\ and -.**\n", {0} }, /* 193 */ {"The road leads to several large buildings here.", {235, 136, 236, 237, 88, 0, 0, 0}, "There is a lighted clubhouse +,* a large barn and stable +, and a\n\ garage of similar construct to the barn +.\n", {0} }, /* 194 */ {"This part of the beach is impassable.", {0, 138, 0, 0, 96, 0, 0, 0}, "The see is calm tonight. The beach goes *-.**\n", {0} }, /* 195 */ {"You are in the gardens.", {195, 140, 197, 138, 96, 0, 0, 0}, "Dew beaded grass sparkles in the moonlight. Tiny lamps beside the path light\n\ the way to the ocean ***+.\n", {0} }, /* 196 */ {"You are in the gardens.", {140, 183, 197, 139, 99, 0, 0, 0}, "Beautiful flowers and shrubs surround a lighted goldfish pond.****\n", {0} }, /* 197 */ {"You are on a stone walk in the garden.", {195, 196, 238, 140, 99, 0, 0, 0}, "The walk leads to a road **+.*\n", {0} }, /* 198 */ {"You are in the forest near the road.", {198, 141, 216, 198, 73, 0, 0, 0}, "There are many thorny bushes here!****\n", {0} }, /* 199 */ {"You are at a fork in the road.", {239, 146, 141, 170, 73, 0, 0, 0}, "Two roads come together in the darkness here. One runs -,* the other \n\ runs - and -.\n", {0} }, /* 200 */ {"You are on a dirt path around the lagoon.", {170, 147, 146, 0, 74, 0, 0, 0}, "The still waters reflect bending palms and a starry sky. It looks like\n\ the path runs into a clearing +. The path continues -.**\n", {0} }, /* 201 */ {"You are drowning in the lagoon.", {201, 201, 147, 201, 74, 0, 0, 0}, "I suggest you get out before you become waterlogged.****\n", {0} }, /* 202 */ {"You are in a coconut palm grove.", {202, 148, 203, 204, 77, 0, 0, 0}, "****\n", {0} }, /* 203 */ {"You are in a palm grove.", {202, 149, 205, 148, 77, 0, 0, 0}, "****\n", {0} }, /* 204 */ {"You are in a palm grove.", {202, 150, 148, 206, 77, 0, 0, 0}, "****\n", {0} }, /* 205 */ {"You are on a dirt road.", {203, 155, 212, 149, 77, 0, 0, 0}, "*This road ends here at a palm grove but continues on - for quite\n\ some way.**\n", {0} }, /* 206 */ {"You are in a coconut palm grove.", {204, 156, 150, 213, 77, 0, 0, 0}, "****\n", {0} }, /* 207 */ {"You are in a coconut grove.", {151, 219, 208, 209, 77, 0, 0, 0}, "*The grove ends +.**\n", {0} }, /* 208 */ {"You are in a coconut grove.", {152, 207, 239, 151, 77, 0, 0, 0}, "**There is a dirt road +.*\n", {0} }, /* 209 */ {"You are in a coconut grove.", {153, 207, 151, 211, 77, 0, 0, 0}, "****\n", {0} }, /* 210 */ {"This is a dirt road.", {205, 239, 212, 154, 77, 0, 0, 0}, "The road continues - and -.**\n", {0} }, /* 211 */ {"You are in a coconut grove.", {153, 209, 153, 213, 77, 0, 0, 0}, "****\n", {0} }, /* 212 */ {"You are in the woods near the road.", {205, 210, 212, 155, 77, 0, 0, 0}, "There are many thorny bushes here!****\n", {0} }, /* 213 */ {"You are in a coconut grove.", {213, 213, 156, 234, 88, 0, 0, 0}, "***The grove ends in a clearing +.\n", {0} }, /* 214 */ {"You are walking along some high cliffs.", {162, 0, 0, 159, 86, 0, 0, 0}, "The island bends sharply + here with high cliffs -\n\ and -. The cliffs are lower +.\n", {0} }, /* 215 */ {"You are at the coast road turn around.", {0, 162, 0, 158, 90, 0, 0, 0}, "The coast road ends here in a lookout with a view of the ocean.\n\ Far below, the waves crash against the rocks.\n\ ****\n", {0} }, /* 216 */ {"You are in the woods near the road.", {216, 163, 216, 198, 79, 0, 257, 0}, "These thorny bushes are killing me.****\n", {0} }, /* 217 */ {"You are in the kitchen.", {0, 0, 0, 165, 0, 0, 0, 0}, "A small gas stove and a refrigerator are all the only appliances here. The\n\ gas oven has been left on and the whole room is reeking with natural gas.\n\ One spark from a match and.... The door out is ***+.\n", {0} }, /* 218 */ {"You are in the bedroom.", {0, 0, 165, 0, 0, 0, 0, 0}, "A soft feather comforter on top of layers of Answer blankets make this a very\n\ luxurious place to sleep indeed. There are also some end tables and a dresser\n\ here.** The living room is +.*\n", {0} }, /* 219 */ {"You are in the woods.", {207, 169, 220, 221, 81, 0, 0, 0}, "The darkness is intense, but there seems to be a clearing +.***\n", {0} }, /* 220 */ {"You are in the woods near the road.", {219, 170, 239, 169, 81, 0, 0, 0}, "*As far as I can tell, there are two roads + and +.*\n", {0} }, /* 221 */ {"You are in the woods.", {207, 171, 219, 222, 81, 0, 0, 0}, "The spider webs thin out and the forest is clearer +.***\n", {0} }, /* 222 */ {"You are on the lagoon's inland finger.", {0, 172, 171, 172, 81, 0, 0, 0}, "It is impossible to follow the lagoon any farther inland because of sharp\n\ and very painful sedges.* The road is +.**\n", {0} }, /* 223 */ {"You are in a grassy coconut grove.", {240, 173, 224, 241, 82, 0, 0, 0}, "The tall palms provide a ghostly canopy for the sandy ground covering.****\n", {0} }, /* 224 */ {"You are near the lagoon's inland finger.", {0, 174, 0, 173, 82, 0, 0, 0}, "Very sharp sedges make it impossible to follow the lagoon any farther inland.\n\ *There is a road +.**\n", {0} }, /* 225 */ {"You are on a dirt road.", {241, 175, 173, 226, 82, 0, 0, 0}, "The road winds through a coconut grove here and continues - and -.**\n", {0} }, /* 226 */ {"You are in the woods near the road.", {226, 226, 175, 226, 82, 0, 0, 0}, "**The road is +.*\n", {0} }, /* 227 */ {"This is a beach?", {227, 227, 177, 0, 82, 0, 0, 0}, "Hard jagged rocks that pierce with every footstep hardly comprise a beach.**\n\ Let's go -.*\n", {0} }, /* 228 */ {"The trail is lost in the woods here.", {241, 241, 179, 241, 84, 0, 0, 0}, "The trail goes **-.*\n", {0} }, /* 229 */ {"You are on the bank of a stream.", {182, 0, 242, 180, 84, 0, 0, 0}, "The stream falls over several small boulders here and continues on **-.*\n", {0} }, /* 230 */ {"You are just inside the cave.", {181, 267, 0, 0, 0, 0, 0, 0}, "A steamy hot breath is belching from the depths of the earth within.* The\n\ cave continues -.**\n", {0} }, /* 231 */ {"You are just inside the cave entrance.", {274, 0, 0, 0, 0, 0, 0, 0}, "The air is hot and sticky inside. The cave continues -. There is a \n\ stone door in the wall +. A wooden sign in the dust warns in old elven\n\ runes, \"GSRF KDIRE NLVEMP!\".**\n", {0} }, /* 232 */ {"You are at the edge of a huge chasm.", {0, 0, 189, 0, 76, 0, 0, 0}, "Several hundred feet down I can see the glimmer of placid water. The\n\ rivulets drain over the edge and trickle down into the depths. It is \n\ impossible to climb down.** The canyon continues -.*\n", {0} }, /* 233 */ {"You are on a dirt road.", {192, 241, 240, 191, 88, 0, 0, 0}, "The road winds through a coconut grove here. The road continues on into the\n\ shadows - and -.**\n", {0} }, /* 234 */ {"You are in a coconut palm grove near the road.", {193, 233, 213, 192, 88, 0, 0, 0}, "***The road is +.\n", {0} }, /* 235 */ {"You are at the clubhouse.", {0, 193, 0, 0, 0, 0, 0, 0}, "The clubhouse is built over the most inland part of the lagoon. Tropical\n\ bananas and fragrant frangipani grow along the grassy shore. Walking across\n\ the short wooden bridge, we enter. Along one wall is a bar crowded with people.\n\ The restaurant and disco dance floor are filled to capacity. A rock group\n\ electrocutes itself to the satisfaction of the audience.****\n", {0} }, /* 236 */ {"You are in the stables.", {0, 0, 0, 193, 0, 0, 0, 0}, "Neighing horses snacking on hay and oats fill the stalls on both sides of\n\ the barn. It is rather warm in here but that is not the most offensive\n\ part.****\n", {0} }, /* 237 */ {"You are in the old garage.", {0, 0, 193, 0, 0, 0, 0, 0}, "This is an old wooden building of the same vintage as the stables. Beneath\n\ a sagging roof stand gardening tools and greasy rags. Parked in the center\n\ is an underpowered Plymouth Volare' with a red and white striped golf cart\n\ roof. ****\n", {0} }, /* 238 */ {"You are on a dirt road.", {197, 197, 243, 197, 85, 0, 0, 0}, "The road leads to a formal garden laced with lighted stone walks and tropical\n\ flowers and trees.** The road continues -. A walk leads -.\n", {0} }, /* 239 */ {"You are on a dirt road.", {210, 199, 198, 220, 73, 0, 0, 0}, "The road runs - and -.**\n", {0} }, /* 240 */ {"You are in a coconut grove near the road.", {234, 223, 234, 233, 88, 0, 0, 0}, "***The road is +.\n", {0} }, /* 241 */ {"You are on a dirt road.", {233, 225, 223, 226, 82, 0, 0, 0}, "The road continues - and -.**\n", {0} }, /* 242 */ {"The stream plummets over a cliff here.", {182, 0, 0, 229, 84, 0, 0, 0}, "Falling 10 agonizing meters into darkness, only droplets of the stream must\n\ be left to dance off the floor below. There is no way down, even with a\n\ strong rope. ****\n", {0} }, /* 243 */ {"You are on a dirt road.", {0, 0, 244, 238, 85, 0, 0, 0}, "**The road continues - and -.\n", {0} }, /* 244 */ {"You are on a dirt road.", {0, 245, 0, 243, 88, 0, 0, 0}, "*The road continues -* and -.\n", {0} }, /* 245 */ {"You are on a dirt road.", {244, 234, 213, 136, 88, 0, 0, 0}, "The road goes -* and *-.\n", {0} }, /* 246 */ {"You are in a low passage.", {247, 160, 0, 0, 0, 0, 0, 0}, "The ceiling here sparkles with iridescent gems and minerals. Colorful starfish\n\ and sea anemones cling to the slippery walls and floor. The passage continues\n\ +.***\n", {0} }, /* 247 */ {"The walls are very close together here.", {248, 246, 0, 0, 0, 0, 0, 0}, "I can barely squeeze through the jagged opening. Slimy sea weeds provide\n\ no footing at all. This tunnel seems to be an ancient lava tube. There is\n\ a large room +.***\n", {0} }, /* 248 */ {"You are in the cathedral room.", {249, 247, 250, 251, 0, 0, 0, 0}, "Your light casts ghostly shadows on the walls but cannot pierce the \n\ engulfing darkness overhead. The sound of water dripping echoes in the void.\n\ *I can see no passages leading out of this room.*** \n", {0} }, /* 249 */ {"You are walking through a very round tunnel.", {252, 248, 0, 0, 252, 1, 0, 0}, "The round walls of this tunnel are amazingly smooth to the touch. A little\n\ trickle of water flows down the center. The tunnel climbs steadily +.\n\ There is a large room +.**\n", {0} }, /* 250 */ {"You are in the cathedral anteroom.", {0, 0, 0, 248, 253, 1, 0, 0}, "This small chamber with a flat stone floor is to one side of the cathedral \n\ room. We appear to be at the bottom of a tall narrow shaft. There are many \n\ puddles of water here. A staircase hewn from solid rock and black lava \n\ leads up.*** The cathedral room is -.\n", {0} }, /* 251 */ {"You are in a wide chamber.", {0, 0, 248, 254, 0, 0, 0, 0}, "Water is sprinkling from the ceiling here. A shallow pool populated by a \n\ myriad of blind white creatures sparkles in your light. Tiny shrimp and\n\ crabs scurry away, frightened by the blinding rays.** The cave \n\ continues + and +.\n", {0} }, /* 252 */ {"You are at the top of a sloping passage.", {0, 249, 255, 256, 257, 1, 249, 0}, "There is much algae growing here, both green and brown specimens. I suspect\n\ that we are near the high tide zone, but no light can get in here. The walls\n\ glisten with shiny minerals.** A hallway here runs + and -.\n", {0} }, /* 253 */ {"You are in an elaborately tiled room.", {0, 0, 258, 0, 0, 0, 250, 0}, "Large colorful tiles plate the floor and walls. The ceiling is a mosaic\n\ of gems set in gold. Hopefully it is only our footsteps that are echoing in\n\ this hollow chamber.** The room continues -. A stone staircase leads\n\ down.*\n", {0} }, /* 254 */ {"You are at a dead end.", {0, 0, 251, 0, 0, 0, 0, 0}, "The walls here are alive with dark mussels. They click their shells menacingly\n\ if we disturb them.** The only exit is +.*\n", {0} }, /* 255 */ {"The tunnel is very low here.", {0, 0, 259, 252, 0, 0, 0, 0}, "You practically have to crawl on your knees to pass through this opening. The\n\ air is stiflingly damp, but you can't hear any sounds of water dripping.**\n\ The crawlspace continues -. The tunnel seems wider +.\n", {0} }, /* 256 */ {"This is the supply room.", {0, 0, 252, 0, 0, 0, 0, 0}, "Picks and shovels line the walls here, as well as hard hats, boxes of\n\ dynamite, and a cartload of very high grade gold and silver ore.** \n\ A tunnel leads off +.*\n", {0} }, /* 257 */ {"You have found a secret entrance to the catacombs", {0, 0, 0, 0, 216, 1, 252, 0}, "Below is a wet, seaweed covered floor. Above is a way out.****\n", {0} }, /* 258 */ {"You are in the catacombs.", {0, 0, 260, 253, 0, 0, 0, 0}, "Ornate tombs and piles of treasure line the walls. Long spears with many\n\ blades, fine swords and coats of mail, heaps of coins, jewelry, pottery, \n\ and golden statues are tribute past kings and queens.** The catacombs\n\ continue - and -.\n", {0} }, /* 259 */ {"You are crawling on your stomach.", {0, 0, 261, 255, 0, 0, 0, 0}, "The passage is quite narrow and jagged, but the rock is no longer lava.\n\ It appears to be a form of granite.** The crawlspace continues -, \n\ but I would just as soon go -.\n", {0} }, /* 260 */ {"You are in the Sepulcher.", {0, 0, 0, 258, 0, 0, 0, 0}, "A single tomb is here. Encrusted with diamonds and opals, and secured with \n\ straps of a very hard, untarnished silver, this tomb must be of a great king.\n\ Vases overflowing with gold coins stand nearby. A line of verse on the wall\n\ reads, \"Three he made and gave them to his daughters.\"****\n", {0} }, /* 261 */ {"The passage is wider here.", {0, 0, 0, 259, 0, 0, 262, 0}, "A ladder goes down into darkness here.*** A small crawlspace goes -.\n", {0} }, /* 262 */ {"You are at the bottom of a ladder.", {0, 0, 0, 0, 261, 1, 263, 0}, "This is a narrow platform to rest on before we continue either up or down this\n\ rickety wooden ladder.****\n", {0} }, /* 263 */ {"You are standing in several inches of water.", {264, 0, 265, 266, 262, 1, 0, 0}, "This seems to be a working mine. Many different tunnels wander off following\n\ glowing veins of precious metal. The floor is flooded here since we must\n\ be nearly at sea level. A ladder leads up.****\n", {0} }, /* 264 */ {"The tunnel here is blocked by broken rocks.", {0, 263, 0, 0, 0, 0, 0, 0}, "The way is blocked, but if you had some dynamite, we might be able to blast our\n\ way through.* The passage goes -.**\n", {0} }, /* 265 */ {"The tunnel is too flooded to proceed.", {0, 0, 0, 263, 0, 0, 0, 0}, "Hidden shafts could swallow us if we tried to continue on down this tunnel.\n\ The flooding is already up to my waist. Large crystals overhead shimmer\n\ rainbows of reflected light.*** Let's go -.\n", {0} }, /* 266 */ {"The mine is less flooded here.", {0, 0, 263, 0, 0, 0, 0, 0}, "A meandering gold laden vein of quartz and blooming crystals of diamonds\n\ and topaz burst from the walls of the cave. A passage goes -.***\n", {0} }, /* 267 */ {"You are inside the cave.", {230, 268, 0, 0, 0, 0, 0, 0}, "A hot steam swirls around our heads, and the walls are warm to the touch.\n\ The trail winds - and -.**\n", {0} }, /* 268 */ {"You are in a rather large chamber.", {267, 0, 0, 269, 0, 0, 269, 0}, "Beds of ferns and palm leaves make several cozy nests along the walls. In the\n\ center of the room is a throne of gold and silver.*** A passageway leads\n\ down and +.\n", {0} }, /* 269 */ {"You are walking along the edge of a huge abyss.", {0, 0, 268, 0, 268, 1, 270, 0}, "Steam is rising in great clouds from the immeasurable depths. A very narrow\n\ trail winds down.** There is a tunnel -.*\n", {0} }, /* 270 */ {"You are on the edge of a huge abyss.", {0, 0, 0, 0, 269, 1, 271, 0}, "The trail winds farther down.****\n", {0} }, /* 271 */ {"You are winding your way along the abyss.", {0, 0, 0, 0, 270, 1, 272, 0}, "The trail continues up and down.****\n", {0} }, /* 272 */ {"You are on a wide shelf near the steamy abyss.", {0, 273, 0, 0, 271, 1, 0, 0}, "The stifling hot cave seems even hotter to me, staring down into this misty \n\ abyss. A trail winds up.* A passageway leads -.**\n", {0} }, /* 273 */ {"You are in a wide tunnel leading to a fuming abyss.", {272, 274, 0, 0, 0, 0, 0, 0}, "The passageway winds through many beautiful formations of crystals and\n\ sparkling minerals. The tunnel continues - and -.**\n", {0} }, /* 274 */ {"You are in a tunnel.", {273, 231, 0, 0, 0, 0, 0, 0}, "It is very warm in here. The smell of steam and hot rocks permeates the place.\n\ The cave continues - and -.**\n", {0} }, /* 275 */ {"You are at the bottom of a pit.", {0, 0, 0, 0, 232, 0, 0, 0}, "At the top of the pit, a single star can be seen in the night sky. There\n\ doesn't appear to be any way to get out without a rope. I don't remember\n\ how we got here.****\n", {0} }, }; bsd-games-2.17/battlestar/extern.h0000664000175000017500000002325610005547567015643 0ustar jsm28jsm28/* $NetBSD: extern.h,v 1.30 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)externs.h 8.1 (Berkeley) 5/31/93 */ #include #include #include #include #include #include #include #include #include #define BITS (8 * sizeof (int)) #define OUTSIDE (position > 68 && position < 246 && position != 218) #define rnd(x) (rand() % (x)) #define max(a,b) ((a) < (b) ? (b) : (a)) #define testbit(array, index) (array[index/BITS] & (1 << (index % BITS))) #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS))) #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS))) /* well known rooms */ #define FINAL 275 #define GARDEN 197 #define POOLS 126 #define DOCK 93 /* word types */ #define VERB 0 #define OBJECT 1 #define NOUNS 2 #define PREPS 3 #define ADJS 4 #define CONJ 5 /* words numbers */ #define KNIFE 0 #define SWORD 1 #define LAND 2 #define WOODSMAN 3 #define TWO_HANDED 4 #define CLEAVER 5 #define BROAD 6 #define MAIL 7 #define HELM 8 #define SHIELD 9 #define MAID 10 #define BODY 10 #define VIPER 11 #define LAMPON 12 #define SHOES 13 #define CYLON 14 #define PAJAMAS 15 #define ROBE 16 #define AMULET 17 #define MEDALION 18 #define TALISMAN 19 #define DEADWOOD 20 #define MALLET 21 #define LASER 22 #define BATHGOD 23 #define NORMGOD 24 #define GRENADE 25 #define CHAIN 26 #define ROPE 27 #define LEVIS 28 #define MACE 29 #define SHOVEL 30 #define HALBERD 31 #define COMPASS 32 #define CRASH 33 #define ELF 34 #define FOOT 35 #define COINS 36 #define MATCHES 37 #define MAN 38 #define PAPAYAS 39 #define PINEAPPLE 40 #define KIWI 41 #define COCONUTS 42 #define MANGO 43 #define RING 44 #define POTION 45 #define BRACELET 46 #define GIRL 47 #define GIRLTALK 48 #define DARK 49 #define TIMER 50 #define CHAR 53 #define BOMB 54 #define DEADGOD 55 #define DEADTIME 56 #define DEADNATIVE 57 #define NATIVE 58 #define HORSE 59 #define CAR 60 #define POT 61 #define BAR 62 #define BLOCK 63 #define NUMOFOBJECTS 64 /* non-objects below */ #define UP 1000 #define DOWN 1001 #define AHEAD 1002 #define BACK 1003 #define RIGHT 1004 #define LEFT 1005 #define TAKE 1006 #define USE 1007 #define LOOK 1008 #define QUIT 1009 #define NORTH 1010 #define SOUTH 1011 #define EAST 1012 #define WEST 1013 #define SU 1014 #define DROP 1015 #define TAKEOFF 1016 #define DRAW 1017 #define PUTON 1018 #define WEARIT 1019 #define PUT 1020 #define INVEN 1021 #define EVERYTHING 1022 #define AND 1023 #define KILL 1024 #define RAVAGE 1025 #define UNDRESS 1026 #define THROW 1027 #define LAUNCH 1028 #define LANDIT 1029 #define LIGHT 1030 #define FOLLOW 1031 #define KISS 1032 #define LOVE 1033 #define GIVE 1034 #define SMITE 1035 #define SHOOT 1036 #define ON 1037 #define OFF 1038 #define TIME 1039 #define SLEEP 1040 #define DIG 1041 #define EAT 1042 #define SWIM 1043 #define DRINK 1044 #define DOOR 1045 #define SAVE 1046 #define RIDE 1047 #define DRIVE 1048 #define SCORE 1049 #define BURY 1050 #define JUMP 1051 #define KICK 1052 #define OPEN 1053 #define VERBOSE 1054 #define BRIEF 1055 #define AUXVERB 1056 /* injuries */ #define ARM 6 /* broken arm */ #define RIBS 7 /* broken ribs */ #define SPINE 9 /* broken back */ #define SKULL 11 /* fractured skull */ #define INCISE 10 /* deep incisions */ #define NECK 12 /* broken NECK */ #define NUMOFINJURIES 13 /* notes */ #define CANTLAUNCH 0 #define LAUNCHED 1 #define CANTSEE 2 #define CANTMOVE 3 #define JINXED 4 #define DUG 5 #define NUMOFNOTES 6 /* Number of times room description shown. */ #define ROOMDESC 3 /* fundamental constants */ #define NUMOFROOMS 275 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS) #define LINELENGTH 81 #define TODAY 0 #define TONIGHT 1 #define CYCLE 100 /* initial variable values */ #define TANKFULL 250 #define TORPEDOES 10 #define MAXWEIGHT 60 #define MAXCUMBER 10 /* * These are flags for objects in the objflags array. OBJ_PLURAL means * that the object short name is plural; OBJ_AN that it begins with a * vowel sound so should be preceded by "an" instead of "a"; OBJ_PERSON * that it is a living person; OBJ_NONOBJ that it is not an object (to * which any game action can be applied) at all (e.g. footsteps, asteroids). * Any individual object has at most one of OBJ_PERSON and OBJ_NONOBJ. */ #define OBJ_PLURAL 1 #define OBJ_AN 2 #define OBJ_PERSON 4 #define OBJ_NONOBJ 8 struct room { const char *name; int link[8]; #define north link[0] #define south link[1] #define east link[2] #define west link[3] #define up link[4] #define access link[5] #define down link[6] #define flyhere link[7] const char *desc; unsigned int objects[NUMOFWORDS]; }; extern struct room dayfile[]; extern struct room nightfile[]; extern struct room *location; /* object characteristics */ extern const char *const objdes[NUMOFOBJECTS]; extern const char *const objsht[NUMOFOBJECTS]; extern const char *const ouch[NUMOFINJURIES]; extern const int objwt[NUMOFOBJECTS]; extern const int objcumber[NUMOFOBJECTS]; extern const int objflags[NUMOFOBJECTS]; #define is_plural_object(n) (objflags[(n)] & OBJ_PLURAL) /* * These macros yield words to use with objects (followed but not preceded * by spaces, or with no spaces if the expansion is the empty string). */ #define A_OR_AN(n) (objflags[(n)] & OBJ_AN ? "an " : "a ") #define A_OR_AN_OR_THE(n) (is_plural_object((n)) ? "the " : A_OR_AN((n))) #define A_OR_AN_OR_BLANK(n) (is_plural_object((n)) ? "" : A_OR_AN((n))) #define IS_OR_ARE(n) (is_plural_object((n)) ? "are " : "is ") /* current input line */ #define WORDLEN 15 #define NWORD 20 /* words per line */ extern char words[NWORD][WORDLEN]; extern int wordvalue[NWORD]; extern int wordtype[NWORD]; extern int wordcount, wordnumber; /* state of the game */ extern int ourtime; extern int position; extern int direction; extern int left, right, ahead, back; extern int ourclock, fuel, torps; extern int carrying, encumber; extern int rythmn; extern int followfight; extern int ate; extern int snooze; extern int meetgirl; extern int followgod; extern int godready; extern int win; extern int wintime; extern int wiz; extern int tempwiz; extern int matchlight, matchcount; extern int loved; extern int pleasure, power, ego; extern int WEIGHT; extern int CUMBER; extern int notes[NUMOFNOTES]; extern unsigned int inven[NUMOFWORDS]; extern unsigned int wear[NUMOFWORDS]; extern char beenthere[NUMOFROOMS + 1]; extern char injuries[NUMOFINJURIES]; extern int verbose; extern const char *username; struct wlist { const char *string; int value, article; struct wlist *next; }; extern struct wlist wlist[]; struct objs { short room; short obj; }; extern const struct objs dayobjs[]; extern const struct objs nightobjs[]; #define DEFAULT_SAVE_FILE ".Bstar" void bury(void); int card(const char *, int); void chime(void); void convert(int); void crash(void); int cypher(void); void die(void) __attribute__((__noreturn__)); void diesig(int) __attribute__((__noreturn__)); void dig(void); void dooropen(void); int draw(void); void drink(void); int drive(void); int drop(const char *); int eat(void); int fight(int, int); int follow(void); char *getcom(char *, int, const char *, const char *); char *getword(char *, char *, int); int give(void); void initialize(const char *); int jump(void); void kiss(void); int land(void); int launch(void); void light(void); void live(void) __attribute__((__noreturn__)); void love(void); int moveplayer(int, int); void murder(void); void news(void); void newway(int); void open_score_file(void); void parse(void); void post(char); void printobjs(void); int put(void); int puton(void); const char *rate(void); void ravage(void); void restore(const char *); int ride(void); void save(const char *); char *save_file_name(const char *, size_t); int shoot(void); int take(unsigned int[]); int takeoff(void); int throw(const char *); const char *truedirec(int, char); int ucard(const unsigned int *); int use(void); int visual(void); int wearit(void); void whichway(struct room); void wordinit(void); void writedes(void); int zzz(void); bsd-games-2.17/battlestar/parse.c0000664000175000017500000001212610005547567015435 0ustar jsm28jsm28/* $NetBSD: parse.c,v 1.14 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: parse.c,v 1.14 2004/01/27 20:30:29 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" #define HASHSIZE 256 #define HASHMUL 81 #define HASHMASK (HASHSIZE - 1) static int hash(const char *); static void install(struct wlist *); static struct wlist *lookup(const char *); static struct wlist *hashtab[HASHSIZE]; void wordinit() { struct wlist *w; for (w = wlist; w->string; w++) install(w); } static int hash(s) const char *s; { int hashval = 0; while (*s) { hashval += *s++; hashval *= HASHMUL; hashval &= HASHMASK; } return hashval; } static struct wlist * lookup(s) const char *s; { struct wlist *wp; for (wp = hashtab[hash(s)]; wp != NULL; wp = wp->next) if (*s == *wp->string && strcmp(s, wp->string) == 0) return wp; return NULL; } static void install(wp) struct wlist *wp; { int hashval; if (lookup(wp->string) == NULL) { hashval = hash(wp->string); wp->next = hashtab[hashval]; hashtab[hashval] = wp; } else printf("Multiply defined %s.\n", wp->string); } void parse() { struct wlist *wp; int n; int flag; wordnumber = 0; /* for cypher */ for (n = 0; n <= wordcount; n++) { if ((wp = lookup(words[n])) == NULL) { wordvalue[n] = -1; wordtype[n] = -1; } else { wordvalue[n] = wp->value; wordtype[n] = wp->article; } } /* We never use adjectives for anything, so yank them all. */ for (n = 1; n < wordcount; n++) if (wordtype[n] == ADJS) { int i; for (i = n + 1; i < wordcount; i++) { wordtype[i - 1] = wordtype[i]; wordvalue[i - 1] = wordvalue[i]; strcpy(words[i - 1], words[i]); } wordcount--; } /* Don't let a comma mean AND if followed by a verb. */ for (n = 0; n < wordcount; n++) if (wordvalue[n] == AND && words[n][0] == ',' && wordtype[n + 1] == VERB) { wordvalue[n] = -1; wordtype[n] = -1; } /* Trim "AND AND" which can happen naturally at the end of a * comma-delimited list. */ for (n = 1; n < wordcount; n++) if (wordvalue[n - 1] == AND && wordvalue[n] == AND) { int i; for (i = n + 1; i < wordcount; i++) { wordtype[i - 1] = wordtype[i]; wordvalue[i - 1] = wordvalue[i]; strcpy(words[i - 1], words[i]); } wordcount--; } /* If there is a sequence (NOUN | OBJECT) AND EVERYTHING * then move all the EVERYTHINGs to the beginning, since that's where * they're expected. We can't get rid of the NOUNs and OBJECTs in * case they aren't in EVERYTHING (i.e. not here or nonexistent). */ flag = 1; while (flag) { flag = 0; for (n = 1; n < wordcount; n++) if ((wordtype[n - 1] == NOUNS || wordtype[n - 1] == OBJECT) && wordvalue[n] == AND && wordvalue[n + 1] == EVERYTHING) { char tmpword[WORDLEN]; wordvalue[n + 1] = wordvalue[n - 1]; wordvalue[n - 1] = EVERYTHING; wordtype[n + 1] = wordtype[n - 1]; wordtype[n - 1] = OBJECT; strcpy(tmpword, words[n - 1]); strcpy(words[n - 1], words[n + 1]); strcpy(words[n + 1], tmpword); flag = 1; } /* And trim EVERYTHING AND EVERYTHING. */ for (n = 1; n < wordcount; n++) if (wordvalue[n - 1] == EVERYTHING && wordvalue[n] == AND && wordvalue[n + 1] == EVERYTHING) { int i; for (i = n + 1; i < wordcount; i++) { wordtype[i - 1] = wordtype[i + 1]; wordvalue[i - 1] = wordvalue[i + 1]; strcpy(words[i - 1], words[i + 1]); } wordcount--; wordcount--; flag = 1; } } } bsd-games-2.17/battlestar/room.c0000664000175000017500000001135507767741711015312 0ustar jsm28jsm28/* $NetBSD: room.c,v 1.11 2003/08/07 09:37:03 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)room.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: room.c,v 1.11 2003/08/07 09:37:03 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" void writedes() { int compass; const char *p; int c; printf("\n\t%s\n", location[position].name); if (beenthere[position] < ROOMDESC || verbose) { compass = NORTH; for (p = location[position].desc; (c = *p++) != 0;) if (c != '-' && c != '*' && c != '+') { if (c == '=') putchar('-'); else putchar(c); } else { if (c != '*') printf(truedirec(compass, c)); compass++; } } } void printobjs() { unsigned int *p = location[position].objects; int n; printf("\n"); for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(p, n) && objdes[n]) puts(objdes[n]); } void whichway(here) struct room here; { switch (direction) { case NORTH: left = here.west; right = here.east; ahead = here.north; back = here.south; break; case SOUTH: left = here.east; right = here.west; ahead = here.south; back = here.north; break; case EAST: left = here.north; right = here.south; ahead = here.east; back = here.west; break; case WEST: left = here.south; right = here.north; ahead = here.west; back = here.east; break; } } const char * truedirec(way, option) int way; char option; { switch (way) { case NORTH: switch (direction) { case NORTH: return ("ahead"); case SOUTH: return (option == '+' ? "behind you" : "back"); case EAST: return ("left"); case WEST: return ("right"); } case SOUTH: switch (direction) { case NORTH: return (option == '+' ? "behind you" : "back"); case SOUTH: return ("ahead"); case EAST: return ("right"); case WEST: return ("left"); } case EAST: switch (direction) { case NORTH: return ("right"); case SOUTH: return ("left"); case EAST: return ("ahead"); case WEST: return (option == '+' ? "behind you" : "back"); } case WEST: switch (direction) { case NORTH: return ("left"); case SOUTH: return ("right"); case EAST: return (option == '+' ? "behind you" : "back"); case WEST: return ("ahead"); } default: printf("Error: room %d. More than four directions wanted.", position); return ("!!"); } } void newway(thisway) int thisway; { switch (direction) { case NORTH: switch (thisway) { case LEFT: direction = WEST; break; case RIGHT: direction = EAST; break; case BACK: direction = SOUTH; break; } break; case SOUTH: switch (thisway) { case LEFT: direction = EAST; break; case RIGHT: direction = WEST; break; case BACK: direction = NORTH; break; } break; case EAST: switch (thisway) { case LEFT: direction = NORTH; break; case RIGHT: direction = SOUTH; break; case BACK: direction = WEST; break; } break; case WEST: switch (thisway) { case LEFT: direction = SOUTH; break; case RIGHT: direction = NORTH; break; case BACK: direction = EAST; break; } break; } } bsd-games-2.17/battlestar/dayfile.c0000664000175000017500000017121107767741711015751 0ustar jsm28jsm28/* $NetBSD: dayfile.c,v 1.12 2003/08/07 09:37:01 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)dayfile.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: dayfile.c,v 1.12 2003/08/07 09:37:01 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" struct room dayfile[] = { {0, {0}, 0, {0} }, /* 1 */ {"You are in the main hangar.", {5, 2, 9, 3, 3, 1, 0, 0}, "This is a huge bay where many fighters and cargo craft lie. Alarms are \n\ sounding and fighter pilots are running to their ships. Above is a gallery\n\ overlooking the bay. The scream of turbo engines is coming from +. The rest\n\ of the hangar is +. There is an exit +.*\n", {0} }, /* 2 */ {"This is the landing bay.", {1, 0, 10, 0, 0, 0, 0, 0}, "Ships are landing here, some heavily damaged. Enemy fighters continually\n\ strafe this vulnerable port. The main hangar is +. *\n\ There is an exit +.*\n", {0} }, /* 3 */ {"You are in the gallery.", {4, 0, 0, 0, 0, 0, 1, 0}, "From here a view of the entire landing bay reveals that our battlestar\n\ is near destruction. Fires are spreading out of control and laser blasts\n\ lick at the shadows. The control room is +. ***\n", {0} }, /* 4 */ {"You are in the control room.", {0, 3, 0, 0, 0, 0, 5, 0}, "Several frantic technicians are flipping switches wildly but otherwise\n\ this room seems fairly deserted. A weapons locker has been left open.\n\ A staircase leads down. * There is a way -. ** \n", {0} }, /* 5 */ {"This is the launch room.", {6, 1, 7, 0, 4, 1, 0, 0}, "From the launch tubes here fighters blast off into space. Only one is left,\n\ and it is guarded by two fierce men. A staircase leads up from here.\n\ There is a cluttered workbench +. From the main hangar come sounds of great\n\ explosions. The main hangar is +. The viper launch tubes are -.*\n", {0} }, /* 6 */ {"You are at the workbench.", {0, 5, 7, 0, 0, 0, 0, 0}, "Strange and unwieldy tools are arranged here including a lunch box \n\ and pneumatic wrenches and turbo sprocket rockets.*\n\ The launch room is +. The remaining viper is +.*\n", {0} }, /* 7 */ {"You are in the viper launch tube.", {0, 5, 0, 5, 32, 0, 0, 0}, "The two guards are eyeing you warily! ****\n", {0} }, /* 8 */ {"This is a walk in closet.", {22, 0, 0, 0, 0, 0, 0, 0}, "A wardrobe of immense magnitude greets the eye. Furs and robes of kings\n\ hang on rack after rack. Silken gowns, capes woven with spun gold, and \n\ delicate synthetic fabrics are stowed here. The bedroom is +.***\n", {0} }, /* 9 */ {"You are in a wide hallway leading to the main hangar.", {0, 0, 11, 1, 0, 0, 0, 0}, "The walls and ceiling here have been blasted through in several places.\n\ It looks as if quite a battle has been fought for possession of the landing bay\n\ Gaping corpses litter the floor.** The hallway continues +.\n\ The main hangar is +.\n", {0} }, /* 10 */ {"You are in a wide hallway leading to the landing bay.", {0, 0, 12, 2, 0, 0, 0, 0}, "Most of the men and supplies needed in the main hangar come through this\n\ corridor, but the wounded are forced to use it too. It very dank and\n\ crowded here, and the floor is slippery with blood.**\n\ The hallway continues -. The landing bay is +.\n", {0} }, /* 11 */ {"The hallway is very congested with rubble here.", {0, 0, 0, 9, 13, 1, 0, 0}, "It is too choked with broken steel girders and other debris to continue\n\ on much farther. Above, the ceiling has caved in and it is possible to \n\ climb up. There is not much chance to go -, -, or -.\n\ But the hallway seems clearer +.\n", {0} }, /* 12 */ {"A wide hallway and a more narrow walkway meet here.", {14, 15, 0, 10, 0, 0, 0, 0}, "The intersection is crowded with the many wounded who have come up\n\ the wide hallway and continued +. The walkway is less crowded +.\n\ The wide hallway goes *-.\n", {0} }, /* 13 */ {"You are in what was once an elegant stateroom.", {16, 0, 0, 0, 0, 0, 11, 0}, "Whoever lived in this stateroom, he and his female companion\n\ were mercilessly slain in their sleep. Clothes, trinkets and personal\n\ belongings are scattered all across the floor. Through a hole in the\n\ collapsed floor I can see a hallway below. A door is +.***\n", {0} }, /* 14 */ {"You're at the entrance to the sick bay.", {17, 12, 18, 0, 0, 0, 0, 0}, "The wounded are entering the sick bay in loudly moaning files.\n\ The walkway continues - and +. A doctor is motioning for you to \n\ come to the -. *\n", {0} }, /* 15 */ {"You're in the walkway.", {12, 19, 0, 0, 0, 0, 0, 0}, "Most of the men and supplies were coming from the armory. The walkway\n\ continues -. The armory is +.**\n", {0} }, /* 16 */ {"These are the executive suites of the battlestar.", {20, 13, 21, 22, 23, 1, 24, 0}, "Luxurious staterooms carpeted with crushed velvet and adorned with beaten\n\ gold open onto this parlor. A wide staircase with ivory banisters leads\n\ up or down. This parlor leads into a hallway +. The bridal suite is\n\ +. Other rooms lie - and +.\n", {0} }, /* 17 */ {"You're in a long dimly lit hallway.", {0, 14, 25, 0, 0, 0, 0, 0}, "This part of the walkway is deserted. There is a dead end +. The\n\ entrance to the sickbay is +. The walkway turns sharply -.*\n", {0} }, /* 18 */ {"This is the sick bay.", {0, 0, 0, 14, 0, 0, 0, 0}, "Sinister nurses with long needles and pitiful aim probe the depths of suffering\n\ here. Only the mortally wounded receive medical attention on a battlestar,\n\ but afterwards they are thrown into the incinerators along with the rest.**\n\ Nothing but death and suffering +. The walkway is +.\n", {0} }, /* 19 */ {"You're in the armory.", {15, 26, 0, 0, 0, 0, 0, 0}, "An armed guard is stationed here 365 sectars a yarn to protect the magazine.\n\ The walkway is +. The magazine is +.**\n", {0} }, /* 20 */ {"The hallway ends here at the presidential suite.", {27, 16, 0, 0, 0, 0, 0, 0}, "The door to this suite is made from solid magnesium, and the entryway is\n\ inlaid with diamonds and fire opals. The door is ajar +. The hallway\n\ goes -.**\n", {0} }, /* 21 */ {"This is the maid's utility room.", {0, 0, 0, 16, 0, 0, 0, 0}, "What a gruesome sight! The maid has been brutally drowned in a bucket of\n\ Pine Sol and repeatedly stabbed in the back with a knife.***\n\ The hallway is +.\n", {0} }, /* 22 */ {"This is a luxurious stateroom.", {0, 8, 16, 0, 0, 0, 0, 0}, "The floor is carpeted with a soft animal fur and the great wooden furniture\n\ is inlaid with strips of platinum and gold. Electronic equipment built\n\ into the walls and ceiling is flashing wildly. The floor shudders and\n\ the sounds of dull explosions rumble though the room. From a window in\n\ the wall + comes a view of darkest space. There is a small adjoining\n\ room +, and a doorway +.*\n", {0} }, /* 23 */ {"You are at the entrance to the dining hall.", {0, 0, 28, 0, 0, 0, 16, 0}, "A wide staircase with ebony banisters leads down here.**\n\ The dining hall is -.*\n", {0} }, /* 24 */ {"This was once the first class lounge.", {0, 0, 29, 0, 16, 1, 0, 0}, "There is much rubble and destruction here that was not apparent elsewhere.\n\ The walls and ceilings have broken in in some places. A staircase with\n\ red coral banisters leads up. It is impossible to go - or -.\n\ It seems a little clearer +.*\n", {0} }, /* 25 */ {"You are in a narrow stairwell.", {0, 17, 0, 0, 30, 1, 0, 0}, "These dusty and decrepit stairs lead up. There is no way -. The\n\ hallway turns sharply -.**\n", {0} }, /* 26 */ {"You are in the magazine.", {19, 0, 0, 0, 0, 0, 0, 0}, "Rows and rows of neatly stacked ammunition for laser pistols and grenade\n\ launchers are here. The armory is +.***\n", {0} }, /* 27 */ {"You're in the presidential suite.", {0, 20, 0, 0, 0, 0, 0, 0}, "Apparently the president has been assassinated. A scorched figure lies\n\ face downward on the carpet clutching his chest.*\n\ The hallway leads -.**\n", {0} }, /* 28 */ {"You are in the dining hall.", {0, 30, 31, 23, 0, 0, 0, 0}, "This was the scene of a mass suicide. Hundreds of ambassadors and assorted\n\ dignitaries sit slumped over their breakfast cereal. I suppose the news\n\ of the cylon attack killed them. There is a strange chill in this room. I\n\ would not linger here. * The kitchen is +. Entrances + and +.\n", {0} }, /* 29 */ {"The debris is very thick here.", {0, 11, 0, 24, 0, 0, 0, 0}, "Broken furniture, fallen girders, and other rubble block the way.\n\ There is not much chance to continue -, -, or -.\n\ It would be best to go -.\n", {0} }, /* 30 */ {"You are in the kitchen.", {28, 0, 0, 0, 0, 0, 0, 0}, "This room is full of shining stainless steel and burnished bronze cookware. An \n\ assortment of tropical fruits and vegetables as well as fine meats and cheeses \n\ lies on a sterling platter. The chef, unfortunately, has been skewered like a \n\ side of beef. The dining room is +. ** There is a locked door +.\n", {0} }, /* 31 */ {"You are in an arched entry leading to the dining room.", {0, 0, 0, 28, 0, 0, 0, 0}, "The door leading out is bolted shut from the outside and is very strong.***\n\ The dining room is +.\n", {0} }, /* 32 */ {"You are in space.", {33, 34, 35, 36, 37, 1, 33, 1}, "****\n", {0} }, /* 33 */ {"You are in space.", {38, 32, 39, 40, 41, 1, 42, 1}, "****\n", {0} }, /* 34 */ {"You are in space.", {32, 44, 45, 46, 47, 1, 48, 1}, "****\n", {0} }, /* 35 */ {"You are in space.", {40, 45, 49, 32, 50, 1, 51, 1}, "****\n", {0} }, /* 36 */ {"You are in space.", {41, 46, 32, 52, 53, 1, 54, 1}, "****\n", {0} }, /* 37 */ {"You are in space.", {42, 47, 50, 53, 55, 1, 32, 1}, "****\n", {0} }, /* 38 */ {"You are in space.", {43, 48, 51, 54, 32, 1, 56, 1}, "****\n", {0} }, /* 39 */ {"You are in space.", {57, 33, 40, 41, 42, 1, 43, 1}, "****\n", {0} }, /* 40 */ {"You are in space.", {39, 35, 57, 33, 58, 1, 59, 1}, "****\n", {0} }, /* 41 */ {"You are in space.", {39, 36, 33, 59, 60, 1, 61, 1}, "****\n", {0} }, /* 42 */ {"You are in space.", {39, 37, 58, 60, 62, 1, 33, 1}, "****\n", {0} }, /* 43 */ {"You are in space.", {39, 38, 59, 61, 33, 1, 63, 1}, "****\n", {0} }, /* 44 */ {"You are in space.", {34, 64, 45, 46, 47, 1, 48, 1}, "****\n", {0} }, /* 45 */ {"You are in space.", {35, 44, 49, 34, 50, 1, 51, 1}, "****\n", {0} }, /* 46 */ {"You are in space.", {36, 44, 34, 52, 53, 1, 54, 1}, "****\n", {0} }, /* 47 */ {"You are in space.", {37, 44, 50, 53, 55, 1, 34, 1}, "****\n", {0} }, /* 48 */ {"You are in space.", {38, 44, 51, 54, 34, 1, 56, 1}, "****\n", {0} }, /* 49 */ {"You are in space.", {49, 49, 52, 35, 49, 1, 49, 1}, "****\n", {0} }, /* 50 */ {"You are in space.", {58, 47, 49, 37, 55, 1, 35, 1}, "****\n", {0} }, /* 51 */ {"You are in space.", {59, 48, 49, 38, 35, 1, 56, 1}, "****\n", {0} }, /* 52 */ {"You are in space.", {52, 52, 36, 49, 52, 1, 52, 1}, "****\n", {0} }, /* 53 */ {"You are in space.", {60, 46, 37, 52, 55, 1, 36, 1}, "****\n", {0} }, /* 54 */ {"You are in space.", {61, 48, 38, 52, 36, 1, 56, 1}, "****\n", {0} }, /* 55 */ {"You are in space.", {62, 55, 55, 55, 56, 1, 37, 1}, "****\n", {0} }, /* 56 */ {"You are in space.", {56, 56, 56, 56, 38, 1, 55, 1}, "****\n", {0} }, /* 57 */ {"You are in space.", {65, 39, 57, 57, 57, 1, 57, 1}, "****\n", {0} }, /* 58 */ {"You are in space.", {39, 50, 49, 42, 62, 1, 40, 1}, "****\n", {0} }, /* 59 */ {"You are in space.", {39, 51, 49, 43, 40, 1, 63, 1}, "****\n", {0} }, /* 60 */ {"You are in space.", {39, 53, 43, 59, 62, 1, 41, 1}, "****\n", {0} }, /* 61 */ {"You are in space.", {39, 54, 43, 59, 41, 1, 56, 1}, "****\n", {0} }, /* 62 */ {"You are in space.", {39, 55, 62, 62, 56, 1, 42, 1}, "****\n", {0} }, /* 63 */ {"You are in space.", {39, 56, 35, 36, 43, 1, 55, 1}, "****\n", {0} }, /* 64 */ {"You are in space.", {44, 66, 66, 66, 66, 1, 66, 1}, "****\n", {0} }, /* 65 */ {"You are in space.", {67, 57, 67, 67, 67, 1, 67, 1}, "****\n", {0} }, /* 66 */ {"You are in space.", {64, 68, 68, 68, 68, 1, 68, 1}, "****\n", {0} }, /* 67 */ {"You are orbiting a small blue planet.", {67, 67, 67, 67, 65, 1, 69, 1}, "****\n", {0} }, /* 68 */ {"You are orbiting a tropical planet.", {68, 68, 68, 68, 66, 1, 70, 1}, "****\n", {0} }, /* 69 */ {"You are flying through a dense fog.", {69, 69, 69, 69, 69, 1, 69, 1}, "A cold grey sea of mist is swirling around the windshield and water droplets\n\ are spewing from the wingtips. Ominous shadows loom in the darkness and it\n\ feels as if a trap is closing around us. I have lost all sense of direction.\n\ ****\n", {0} }, /* 70 */ {"You are approaching an island.", {71, 72, 73, 74, 68, 1, 0, 1}, "Coconut palms, sword ferns, orchids, and other lush vegetation drape this\n\ jagged island carved seemingly from pure emerald and set in a turquoise\n\ sea. The land rises sharply +. There is a nice beach* +.*\n", {0} }, /* 71 */ {"You are flying over a mountainous region.", {75, 73, 76, 77, 68, 1, 0, 1}, "Below is a magnificent canyon with deep gorges, high pinnacles and\n\ waterfalls plummeting hundreds of feet into mist. Everything in sight\n\ is carpeted with a tropical green.* The ocean is +.**\n", {0} }, /* 72 */ {"You are flying over the ocean.", {74, 78, 78, 78, 68, 1, 0, 1}, "You bank over the water and your wingtips dip low to the green waves. The\n\ sea is very shallow here and the white coral beds beneath us teem with \n\ colorful fish.****\n", {0} }, /* 73 */ {"You are flying over the beach.", {71, 72, 79, 74, 68, 1, 80, 1}, "A warm gentle surf caresses the white coral beach here. The land rises\n\ sharply +.* The beach is lost in low cliffs and rocks +.*\n", {0} }, /* 74 */ {"You are flying over a large lagoon.", {81, 72, 73, 82, 68, 1, 0, 1}, "Encircled by a coral reef, the palms and ferns in this sheltered spot\n\ have grown down to the water's very brink which winds tortuously inland.\n\ There looks like a small village +.***\n", {0} }, /* 75 */ {"You are flying over a gently sloping plane.", {83, 71, 84, 85, 68, 1, 0, 1}, "This is where several alluvial fans and ancient lava flows have run\n\ together forming a fertile plane choked with vegetation. It would be\n\ impossible to land safely here.* The terrain is more rugged +.**\n", {0} }, /* 76 */ {"You are flying through a gorge.", {0, 0, 86, 71, 68, 1, 102, 1}, "This narrow, steep sided canyon is lined with waving ferns. The floor is of\n\ light gravel with many freshets pouring from the walls and running along it.\n\ The gorge leads to the sea** +, and to a tumultuous origin +.\n", {0} }, /* 77 */ {"You are flying over a plantation.", {85, 81, 71, 88, 68, 1, 89, 1}, "Rows of palms, papayas, mangoes, kiwi, as well as smaller fields of sugar\n\ cane and pineapple are growing here. It might be possible to land here, but\n\ I wouldn't advise it.* There looks like two small settlements + \n\ and *+.\n", {0} }, /* 78 */ {"You are over the ocean.", {72, 78, 79, 74, 68, 1, 0, 1}, "The deep green swells foam and roll into the shore **+*.\n", {0} }, /* 79 */ {"You are flying along the coast.", {86, 72, 90, 73, 68, 1, 91, 1}, "The coastline here is very rocky with little or no sand. The surf in some\n\ places is violent and explodes in a shower of sparkling spray.\n\ There is a winding road below which closely follows the shore. ****\n", {0} }, /* 80 */ {"This is a beautiful coral beach.", {106, 0, 107, 108, 73, 0, 0, 0}, "Fine silver sand kissed lightly by warm tropical waters stretches at least\n\ 30 meters here from the ocean to under gently swaying palms +.***\n", {0} }, /* 81 */ {"You are flying over a small fishing village.", {77, 74, 71, 82, 68, 1, 92, 1}, "A few thatched huts a short distance from the water and row of more modern\n\ bungalows on either side of a dirt road are all that is here. The road\n\ continues on ***+.\n", {0} }, /* 82 */ {"You are flying over a clearing.", {88, 72, 74, 87, 68, 1, 93, 1}, "There is a dock here (big enough for a seaplane) leading to a grassy\n\ meadow and a road. Some people are having a party down there. Below is\n\ a good landing site. ****\n", {0} }, /* 83 */ {"You are flying over the shore.", {94, 75, 95, 96, 68, 1, 0, 1}, "Rocky lava flows or coarse sandy beaches are all that is here except for\n\ sparse herbs and weeds.****\n", {0} }, /* 84 */ {"You are flying in a wide valley.", {95, 97, 86, 75, 68, 1, 98, 1}, "This is a shallow valley yet the floor is obscured by a thick mist.\n\ The valley opens to the sea +. The mist grows thicker +.**\n", {0} }, /* 85 */ {"You are flying near the shore.", {96, 77, 75, 99, 68, 1, 0, 1}, "Very tall palm trees growing in neatly planted rows march off from the \n\ water here towards the hills and down to the flat lands *+.*\n\ There is a nice beach +.\n", {0} }, /* 86 */ {"You are flying around the very tip of the island.", {95, 79, 90, 84, 68, 1, 0, 1}, "There is no beach here for sheer cliffs rise several hundred feet\n\ to a tree covered summit. Far below, the blue sea gnaws voraciously at\n\ the roots of these cliffs. The island bends around +** and +.\n", {0} }, /* 87 */ {"You are flying along the coastline.", {99, 82, 88, 100, 68, 1, 101, 1}, "There is a narrow strip of sand here lined with ferns and shrubs, but very\n\ few trees. The beach is barley wide enough to land on. The beach continues\n\ on -.* There are some buildings +.*\n", {0} }, /* 88 */ {"You are flying over several cottages and buildings", {99, 82, 77, 87, 68, 1, 103, 1}, "The grounds here are landscaped with palm trees, ferns, orchids, and beds of\n\ flowering plumeria and antheriums. Directly below is a small ornate white\n\ house with a belltower, a lush green lawn, and a spurting fountain.\n\ Small dirt roads go + and +.**\n", {0} }, /* 89 */ {"You are in a field of sugar cane.", {109, 110, 111, 112, 77, 0, 0, 0}, "These strong, thick canes give little shelter but many cuts and scrapes.\n\ There are some large trees ***+.\n", {0} }, /* 90 */ {"You are flying over the ocean.", {95, 78, 90, 86, 68, 1, 0, 1}, "The water is a placid turquoise and so clear that fish and sharks\n\ many fathoms below are clearly visible.****\n", {0} }, /* 91 */ {"You are on the coast road.", {113, 114, 115, 116, 79, 0, 0, 0}, "The road winds close to the shore here and the sound of crashing surf is\n\ deafening.* The water is +. The road continues - and -.\n", {0} }, /* 92 */ {"You are on the main street of the village.", {117, 118, 119, 120, 81, 0, 0, 0}, "Thatched roofs and outrigger canoes, palm trees and vacation bungalows, and\n\ comely natives in a tropical paradise all make this a fantasy come true.\n\ There is an open bungalow +.* The road continues - and -.\n", {0} }, /* 93 */ {"You are at the sea plane dock.", {121, 122, 123, 124, 82, 0, 0, 0}, "Native girls with skin of gold, clad only in fragrant leis and lavalavas,\n\ line the dockside to greet you. A couple of ukulele=plucking islanders and a\n\ keyboard player are adding appropriate music. A road crosses the clearing \n\ +*. There are some tables set up +.*\n", {0} }, /* 94 */ {"You are flying over the ocean.", {94, 83, 95, 96, 68, 1, 0, 1}, "Sea weeds and kelp surge in the waves off shore here. The ocean becomes \n\ much deeper +.***\n", {0} }, /* 95 */ {"You are flying along the coast.", {94, 84, 86, 83, 68, 1, 0, 1}, "The land is very low here with a river running into the sea +. There\n\ is a wide valley opening up +. The very tip of the island is +.*\n", {0} }, /* 96 */ {"You are flying along the coast.", {94, 85, 83, 99, 68, 1, 0, 1}, "There are some secluded sandy stretches of beach here, but too many rocky\n\ outcroppings of lava to land. There is a nicer beach ***+.\n", {0} }, /* 97 */ {"You are lost in a sea of fog.", {97, 104, 97, 97, 97, 1, 0, 1}, "What have you gotten us into?\n\ I can't see a thing! ****\n", {0} }, /* 98 */ {"You are on a gravel wash.", {125, 126, 127, 128, 84, 0, 0, 0}, "The sound of cascading water is the background for a diluted chorus of \n\ gurgling, splashing, and enchantingly delicate singing. Great billows\n\ of steam are rising *+.**\n", {0} }, /* 99 */ {"You are flying over a wide beach.", {96, 88, 85, 87, 68, 1, 105, 1}, "Unlike the leeward beaches, few coconut palms grow here but a well groomed\n\ lawn and garden with traipsing stone walks leads down to the sand.*\n\ There are some buildings +. Some trees are growing +.*\n", {0} }, /* 100 */ {"You are flying over the ocean.", {100, 100, 87, 100, 68, 1, 0, 1}, "The sea is a perfectly clear blue with a white sandy bottom. No coral\n\ grows underwater here, but the force of the waves is broken by the steep\n\ incline.****\n", {0} }, /* 101 */ {"You are on a narrow strip of sand.", {129, 130, 131, 0, 87, 0, 0, 0}, "Rather coarse sand makes this beach very steep and only a few meters wide.\n\ A fresh ocean breeze is rustling the ferns **+.*\n", {0} }, /* 102 */ {"This is Fern Canyon.", {0, 0, 132, 133, 76, 0, 0, 0}, "Delicate waving ferns flourish here, suckled by warm water dripping from \n\ every fissure and crevice in the solid rock walls.\n\ The canyon winds **-, and -.\n", {0} }, /* 103 */ {"This is the front lawn.", {134, 135, 136, 137, 88, 0, 0, 0}, "There is a small fountain here where the driveway meets the lawn.\n\ Across the driveway, +, is an ornate white house with and elegant \n\ woodworking. The bargeboards are carved with fylfots, the ancient \n\ symbols of luck. Even a bell tower has been built here.* There is a \n\ road + which turns into the driveway.*\n", {0} }, /* 104 */ {"You have just crossed the crest of a mountain.", {97, 79, 86, 71, 68, 1, 0, 1}, "The fog vanished mysteriously as we flew over the crest.*\n\ Far + I can see the ocean.**\n", {0} }, /* 105 */ {"You are on a sandy beach.", {138, 139, 140, 0, 99, 0, 0, 0}, "This is the only good beach on the weather side of the island. Fine coral\n\ sand, a fresh sea breeze, and dramatic surf add to its appeal.**\n\ Stone steps lead to the gardens +.*\n", {0} }, /* 106 */ {"You are among palm trees near the shore.", {141, 80, 142, 143, 73, 0, 0, 0}, "Arching coconut palms laden with fruit provide a canopy for the glistening\n\ white sand and sparse grasses growing here. The forest grows denser +.\n\ The ocean is +.**\n", {0} }, /* 107 */ {"You are walking along the beach.", {144, 0, 145, 80, 73, 0, 0, 0}, "The warm tropical waters nuzzle your ankles as you walk. Above is a fiercely\n\ blue sky. The slope of the sand is so gentle that two hundred meters\n\ offshore the water is only knee deep.** There are some rocks +.*\n", {0} }, /* 108 */ {"You are walking along the beach.", {146, 0, 80, 147, 73, 0, 0, 0}, "Many beautiful shells have been washed up here including bright yellow \n\ cowries, chocolate colored murex, orange conches, striped tritons and the\n\ deadly cone shells.****\n", {0} }, /* 109 */ {"You are in a papaya grove.", {148, 89, 149, 150, 77, 0, 0, 0}, "Green slender trees no taller than three meters bulge with their\n\ orange succulent fruit. There are some tall trees +.***\n", {0} }, /* 110 */ {"You are in a field of pineapple.", {89, 151, 152, 153, 77, 0, 0, 0}, "The sharp dagger like pineapple leaves can pierce the flesh and hold fast\n\ a skewered victim with tiny barbs.* The field ends +.**\n", {0} }, /* 111 */ {"You are in a field of kiwi plants.", {149, 154, 155, 89, 77, 0, 0, 0}, "Round hairy fruit hang from staked vines here. There are some trees +\n\ and +. The field ends in a dirt road +.*\n", {0} }, /* 112 */ {"You are in a large grove of coconuts.", {150, 153, 89, 156, 77, 0, 0, 0}, "These trees are much taller than any growing near the shore plus the fat,\n\ juicy coconuts have been selectively cultivated. The grove continues\n\ +, +, *and +.\n", {0} }, /* 113 */ {"You are in the woods.", {157, 91, 158, 116, 79, 0, 0, 0}, "Tropical undergrowth makes the going rough here. Sword ferns give no strong\n\ foot hold and the dangling vines would gladly throttle one. Strange cackling\n\ noises are coming from somewhere +.***\n", {0} }, /* 114 */ {"You are at the shore.", {91, 0, 159, 145, 79, 0, 0, 0}, "Explosions of surf jetting out of underwater tunnels here make it\n\ impossible to climb down to a small cave entrance below. Only at rare\n\ minus tides would it be possible to enter.*** The beach is better +.\n", {0} }, /* 115 */ {"You are on the coast road.", {158, 161, 162, 91, 79, 0, 0, 0}, "The road is beginning to turn inland.* I can hear the surf +. The road\n\ continues +.*\n", {0} }, /* 116 */ {"The road winds deeper into the trees.", {163, 142, 91, 164, 79, 0, 0, 0}, "Only narrow sunbeams filter through the foliage above. The moist rich earth\n\ has nurtured a myriad of trees, shrubs, and flowers to grow here. The\n\ road continues - and *- from here.*\n", {0} }, /* 117 */ {"This is the front porch of the bungalow.", {165, 92, 0, 0, 81, 0, 0, 0}, "These wooden steps and porch are very bucolic. A little woven mat on the \n\ doorstep reads \"Don't Tread on Me\". The open front door is +.\n\ A stone walk leads to the main street +.**\n", {0} }, /* 118 */ {"You are on a path leading to the lagoon.", {92, 166, 167, 168, 81, 0, 0, 0}, "This path trampled fern, grass, sapling, and anything else that got in its\n\ way.* The water is +.**\n", {0} }, /* 119 */ {"This is a dirt road.", {169, 118, 170, 92, 81, 0, 0, 0}, "**The road continues on - here for some distance. A village is +.\n", {0} }, /* 120 */ {"You are on a dirt road.", {171, 118, 92, 172, 81, 0, 0, 0}, "**There is a small village +. The road continues +.\n", {0} }, /* 121 */ {"You are on a dirt road.", {173, 93, 174, 175, 82, 0, 0, 0}, "The light tan soil of the road contrasts artistically with the lush green\n\ vegetation and searing blue sky.* There is a clearing and many people +.\n\ The road continues - and -.\n", {0} }, /* 122 */ {"You are at the seaplane dock.", {93, 0, 176, 177, 82, 0, 0, 0}, "Several muscular, bronze skinned men greet you warmly as you pass under\n\ a thatched shelter above the dock here. Polynesian hospitality.\n\ There is a clearing +.* A trail runs around the lagoon + and +.\n", {0} }, /* 123 */ {"There are some tables on the lawn here.", {121, 122, 123, 93, 82, 0, 0, 0}, "Hors d'oeuvres, canapes, mixed drinks, and various narcotic drugs along with\n\ cartons of Di Gel fill the tables to overflowing. Several other guests are\n\ conversing and talking excitedly****.\n", {0} }, /* 124 */ {"You are nosing around in the bushes.", {124, 124, 93, 124, 82, 0, 0, 0}, "There is little here but some old beer cans. You are making fools out of\n\ us in front of the other guests.** It would be best to go -.*\n", {0} }, /* 125 */ {"You are walking in a dry stream bed.", {178, 98, 179, 0, 84, 0, 0, 0}, "The large cobblestones are difficult to walk on. No sunlight reaches\n\ below a white canopy of fog seemingly generated from *+. A dirt path \n\ along the wash is +. A high bank is impossible to climb +.\n", {0} }, /* 126 */ {"You are at the thermal pools.", {98, 0, 180, 181, 84, 0, 0, 0}, "Several steaming fumaroles and spluttering geysers drenched by icy mountain\n\ waters from a nearby waterfall heat half a dozen natural pools to a\n\ delicious 42 degrees. Enchantingly beautiful singing seems to flow from the\n\ water itself as it tumbles down the falls.*** There is a mossy entrance\n\ to a cave +.\n", {0} }, /* 127 */ {"You are in the woods.", {127, 180, 182, 98, 84, 0, 0, 0}, "Coniferous trees girded by wild huckleberries, elderberries, salmonberries\n\ and thimbleberries enjoy a less tropical climate here in the high mountains.\n\ *The sound of rushing water is coming from +.**\n", {0} }, /* 128 */ {"You are on a dirt trail.", {179, 181, 98, 0, 84, 0, 0, 0}, "The trail seems to start here and head -.** High cliffs border the \n\ trail +.\n", {0} }, /* 129 */ {"You are walking along the beach.", {183, 101, 184, 0, 87, 0, 0, 0}, "A rather unnerving surf explodes onto the beach here and dashes itself into\n\ spray on the steep incline. The beach continues + and +.**\n", {0} }, /* 130 */ {"You are walking along the beach.", {101, 185, 186, 0, 87, 0, 0, 0}, "This is not a very nice beach. The coarse sand hurts my feet.****\n", {0} }, /* 131 */ {"You are walking through some ferns.", {184, 186, 187, 101, 87, 0, 0, 0}, "This is a wide field growing only ferns and small shrubs.** The \n\ ocean is *+.\n", {0} }, /* 132 */ {"You are in a narrow canyon.", {0, 0, 188, 102, 76, 0, 0, 0}, "The steep sides here squeeze a little freshet through a gauntlet like\n\ series of riffles and pools.****\n", {0} }, /* 133 */ {"The canyon is much wider here.", {0, 0, 102, 189, 76, 0, 0, 0}, "The sheer rock walls rise 10 meters to the forest above. A slender \n\ waterfall careens away from the face of the rock high above and showers\n\ the gravel floor with sparkling raindrops.** The canyon continues -\n\ and -.\n", {0} }, /* 134 */ {"You are on the front porch of the cottage.", {190, 103, 0, 0, 0, 0, 0, 0}, "Several giggling native girls came running down the steps as you approached\n\ and headed on down the road. On the fern rimmed porch is a small table with\n\ matching white wrought iron chairs cushioned with red velvet. The front\n\ door leads -. The lawn and fountain are +.**\n", {0} }, /* 135 */ {"You are in a palm grove.", {103, 191, 192, 105, 88, 0, 0, 0}, "****\n", {0} }, /* 136 */ {"You are on a dirt road.", {193, 192, 245, 103, 88, 0, 0, 0}, "There is a large village +. The road cleaves a coconut plantation +.\n\ A small dirt road goes -, and a driveway peels off +.\n", {0} }, /* 137 */ {"You are in a field of small shrubs.", {184, 186, 103, 187, 88, 0, 0, 0}, "**Pine and other coniferous saplings have been planted here. The rich brown\n\ soil is well tilled and watered. Across a large lawn, there is a small\n\ cottage +. I can feel a delicious sea breeze blowing from +.\n", {0} }, /* 138 */ {"The beach is pretty rocky here.", {194, 105, 195, 0, 96, 0, 0, 0}, "Dangerous surf and lava outcroppings make this a treacherous strand.\n\ The beach is nicer* +.**\n", {0} }, /* 139 */ {"The beach is almost 10 meters wide here.", {105, 183, 196, 0, 99, 0, 0, 0}, "The sand has become more coarse and the beach steeper.* It gets \n\ worse +.**\n", {0} }, /* 140 */ {"You are in the gardens.", {195, 196, 197, 105, 99, 0, 0, 0}, "Lush green lawns studded with palms and benches stretch as far as the eye\n\ can see.** A path leads -. Stone steps lead down to the beach +.\n", {0} }, /* 141 */ {"You are on the coast road.", {198, 106, 163, 199, 73, 0, 0, 0}, "The forest is dense on either side and conceals the road from anyone\n\ approaching it.** The road continues - and -.\n", {0} }, /* 142 */ {"You are in the forest.", {116, 107, 91, 106, 73, 0, 0, 0}, "There are trees and ferns all around.****\n", {0} }, /* 143 */ {"You are in the forest.", {199, 108, 106, 146, 73, 0, 0, 0}, "There are trees and ferns all around.****\n", {0} }, /* 144 */ {"You are in a copse.", {142, 107, 145, 80, 0, 0, 0, 0}, "This is a secret hidden thicket only noticeable from the beach. Someone\n\ has been digging here recently.****\n", {0} }, /* 145 */ {"You are at the tide pools.", {91, 0, 114, 107, 79, 0, 0, 0}, "These rocks and pools are the home for many sea anemones and crustaceans.\n\ **The surf is very rough +. There is a nice beach +.\n", {0} }, /* 146 */ {"You are in the forest.", {199, 108, 143, 0, 73, 0, 0, 0}, "This is a shallow depression sheltered from the wind by a thick growth of \n\ thorny shrubs. It looks like someone has camped here. There is a fire pit\n\ with some dry sticks and grass nearby.* The beach is +.* The thorny\n\ shrubs block the way -.\n", {0} }, /* 147 */ {"You are at the mouth of the lagoon.", {200, 0, 108, 201, 74, 0, 0, 0}, "The beach ends here where the coral reef rises to form a wide lagoon\n\ bending inland. A path winds around the lagoon to the -.*\n\ The beach continues on -. Only water lies +.\n", {0} }, /* 148 */ {"You are in a breadfruit grove.", {202, 109, 203, 204, 77, 0, 0, 0}, "The tall trees bend leisurely in the breeze, holding many round breadfruits\n\ close to their large serrated leaves. There are coconut palms +,\n\ *+, and +.\n", {0} }, /* 149 */ {"You are in a grove of mango trees.", {203, 111, 205, 109, 77, 0, 0, 0}, "The juicy yellow red fruits are nearly ripe on the trees here. There are\n\ some coconut palms +. There are some vines +. There is a road +.*\n", {0} }, /* 150 */ {"You are in a grove of coconut palms.", {204, 112, 109, 206, 77, 0, 0, 0}, "All I can see around us are palm trees.****\n", {0} }, /* 151 */ {"You are in a coconut grove.", {110, 207, 208, 209, 77, 0, 0, 0}, "There are countless trees here.****\n", {0} }, /* 152 */ {"You are in a field of pineapple.", {154, 208, 210, 110, 77, 0, 0, 0}, "The sharp leaves are cutting me to ribbons. There is a road **+.\n\ More pineapple +.\n", {0} }, /* 153 */ {"You are in a coconut grove.", {112, 209, 110, 211, 77, 0, 0, 0}, "There is a field of pineapple **+.*\n", {0} }, /* 154 */ {"You are on the edge of a kiwi and pineapple field.", {111, 152, 155, 110, 77, 0, 0, 0}, "An irrigation ditch separates the two fields here. There is a road **+.*\n", {0} }, /* 155 */ {"This is a dirt road.", {205, 210, 212, 111, 77, 0, 0, 0}, "The road runs - and - here.**\n", {0} }, /* 156 */ {"You are in a palm grove.", {206, 211, 112, 213, 77, 0, 0, 0}, "There are palm trees all around us.****\n", {0} }, /* 157 */ {"You are on the edge of a small clearing.", {157, 113, 157, 157, 79, 0, 0, 0}, "The ground is rather marshy here and darting in and out of the many tussocks\n\ is a flock of wild chicken like fowl.****\n", {0} }, /* 158 */ {"You are in the woods.", {158, 115, 215, 113, 79, 0, 0, 0}, "You have walked a long way and found only trees. ****\n", {0} }, /* 159 */ {"You are walking along the shore.", {115, 0, 214, 114, 86, 0, 0, 0}, "You are now about 10 meters above the surf on a gently rising cliffside.**\n\ The land rises +. There is a beach far +.\n", {0} }, /* 160 */ {"You are just inside the entrance to the sea cave.", {246, 114, 0, 0, 114, 1, 0, 0}, "The sound of water dripping in darkness and the roar of the ocean just outside\n\ create a very unwelcoming atmosphere inside this cave. Only on rare occasions\n\ such as this is it possible to enter the forbidden catacombs... The cave\n\ continues -.***\n", {0} }, /* 161 */ {"You are in a secret nook beside the road.", {115, 159, 162, 91, 79, 0, 0, 0}, "Hidden from all but the most stalwart snoopers are some old clothes, empty\n\ beer cans and a trash baggie full of used Huggies and ordure. Lets get\n\ back to the road +.***\n", {0} }, /* 162 */ {"You are on the coast road.", {215, 214, 0, 115, 86, 0, 0, 0}, "The road turns abruptly - here, avoiding the cliffs near the shore\n\ + and +.*\n", {0} }, /* 163 */ {"You are on a dirt road.", {216, 116, 113, 141, 79, 0, 0, 0}, "The roadside is choked with broad leaved plants fighting for every breath of\n\ sunshine. The palm trees are taller than at the shore yet bend over the road \n\ forming a canopy. The road continues *- and *-.\n", {0} }, /* 164 */ {"You have discovered a hidden thicket near the road.", {163, 142, 116, 106, 73, 0, 0, 0}, "Stuffed into a little bundle here is a bloody silken robe and many beer cans.\n\ *Some droplets of blood and a major spill sparkle farther +.\n\ The road is +.*\n", {0} }, /* 165 */ {"You are in the living room.", {0, 117, 217, 218, 0, 0, 0, 0}, "A decorative entry with fresh flowers and wall to wall carpeting leads into\n\ the living room here where a couch and two chairs converge with an end table.\n\ *The exit is +.* The bedroom is +.\n", {0} }, /* 166 */ {"You are at the lagoon.", {118, 0, 167, 168, 81, 0, 0, 0}, "There are several outrigger canoes pulled up on a small beach here and a\n\ catch of colorful fish is drying in the sun. There are paths leading \n\ off -*, -, and -.\n", {0} }, /* 167 */ {"You are at the lagoon.", {118, 0, 170, 166, 81, 0, 0, 0}, "This is a grassy little spot near the water. A sightly native girl is frolicking\n\ in the water close to shore here.** The path continues - and -. \n", {0} }, /* 168 */ {"You are at the lagoon.", {118, 0, 166, 172, 81, 0, 0, 0}, "The path meanders through tussocks of grass, ferns, and thorny bushes here\n\ and continues on **- and -.\n", {0} }, /* 169 */ {"You are in the woods.", {219, 119, 220, 92, 81, 0, 0, 0}, "There are plenty of ferns and thorny bushes here! ****\n", {0} }, /* 170 */ {"You are on a dirt road.", {220, 167, 199, 119, 74, 0, 0, 0}, "The road winds rather close to a large lagoon here and many sedges and tall\n\ grasses line the shoulder *+. The road continues - and -.\n", {0} }, /* 171 */ {"You are in the woods beside the road.", {221, 120, 92, 222, 81, 0, 0, 0}, "The forest grows darker +. The road is +.**\n", {0} }, /* 172 */ {"The road crosses the lagoon here.", {222, 0, 120, 174, 81, 0, 0, 0}, "Coursing through the trees, the road at this point bridges a watery finger\n\ of the lagoon.* The water is +. The road continues - and -.\n", {0} }, /* 173 */ {"You are in a coconut palm grove.", {223, 121, 224, 225, 82, 0, 0, 0}, "The tall palms are planted about 30 feet apart with a hardy deep green grass\n\ filling the spaces in between. There are tire tracks through the grass. The\n\ grove continues -. There is a road +.**\n", {0} }, /* 174 */ {"You are walking along a dirt road.", {224, 176, 172, 121, 82, 0, 0, 0}, "You are nearing the lagoon.** The road continues - and -.\n", {0} }, /* 175 */ {"You are on a dirt road.", {225, 177, 121, 226, 82, 0, 0, 0}, "The road turns abruptly - here, entering a grove of palm trees.* The road\n\ also continues - toward the lagoon.*\n", {0} }, /* 176 */ {"You are on a trail running around the lagoon.", {172, 0, 0, 122, 82, 0, 0, 0}, "The dark waters brush the trail here and the path crosses a bridge +.\n\ There is deep water + and +. The trail continues -.\n", {0} }, /* 177 */ {"This is the mouth of the lagoon.", {175, 0, 122, 227, 82, 0, 0, 0}, "The coral reef wraps around a natural bay here to create a wide lagoon which\n\ winds tortuously inland.** A trail goes around the lagoon +. The beach\n\ is +.\n", {0} }, /* 178 */ {"You are in a dry stream bed.", {0, 125, 0, 0, 84, 0, 0, 0}, "The dry wash drains over a tall precipice here into a turbid morass below. The\n\ most noisome stench imaginable is wafting up to defile our nostrils. Above,\n\ the lurid sun glows brown through a strange mist.* The only direction \n\ I'm going is -.**\n", {0} }, /* 179 */ {"You are on a dirt path along the wash.", {0, 128, 125, 228, 84, 0, 0, 0}, "This path looks more like a deer trail. It scampers away ***+.\n", {0} }, /* 180 */ {"The thermal pools flow into a stream here.", {127, 0, 229, 126, 84, 0, 0, 0}, "The gurgling hot waters pour over boulders into a swiftly flowing\n\ stream **+. The pools are +.\n", {0} }, /* 181 */ {"You are at the entrance to a cave.", {128, 230, 126, 0, 84, 0, 0, 0}, "A tall narrow fissure in the rock cliffs here has become a well traveled\n\ passage way. A hoof beaten dirt path leads directly into it. A curl of\n\ steam is trailing from a corner of the fissure's gaping mouth. The path\n\ leads - and -. The pools are +.*\n", {0} }, /* 182 */ {"You are in the woods.", {182, 229, 182, 127, 84, 0, 0, 0}, "Wild berry bushes plump with fruit and thorns tangle your every effort to\n\ proceed.* The sound of rushing water is +.**\n", {0} }, /* 183 */ {"You are walking along the beach.", {139, 129, 184, 0, 99, 0, 0, 0}, "Some dunes here progress inland and make it impossible to get very far in that\n\ direction. The beach continues - and -.* The ocean is +.\n", {0} }, /* 184 */ {"You are in the dunes.", {183, 101, 184, 129, 87, 0, 0, 0}, "The endless rolling and pitching sand dunes are enough to make one very queasy!\n\ The only way I'm going is ***+.\n", {0} }, /* 185 */ {"This is a lousy beach.", {130, 0, 0, 0, 87, 0, 0, 0}, "Volcanic and viciously sharp bitted grains of sand here bite like cold steel\n\ into my tender feet. I refuse to continue on. Let's get out of here. The\n\ beach is better +.***\n", {0} }, /* 186 */ {"You are in a field of sparse ferns.", {131, 185, 187, 130, 87, 0, 0, 0}, "The lava rock outcroppings here will support few plants. There is more \n\ vegetation +. There is a nice beach +.* The ocean is +.\n", {0} }, /* 187 */ {"You are in the woods.", {131, 131, 137, 131, 87, 0, 0, 0}, "Young trees and tall shrubs grow densely together at this distance from the \n\ shore.** The trees grow thicker +.*\n", {0} }, /* 188 */ {"The canyon is no wider than a foot here.", {0, 0, 0, 132, 0, 0, 0, 0}, "The freshet is gushing through the narrow trough, but the canyon has grown\n\ too narrow to follow it any farther.*** I guess we'll have to go -.\n", {0} }, /* 189 */ {"You are in a narrow part of the canyon.", {0, 0, 133, 232, 76, 0, 0, 0}, "The two sheer sides are no more than a few meters apart here. There is a stone\n\ door in the wall +. The gravelly floor runs with tiny rivulets seeping \n\ from the ground itself.* The canyon continues - and -.\n", {0} }, /* 190 */ {"You are in the drawing room.", {0, 134, 0, 0, 0, 0, 0, 0}, "Exquisitely decorated with plants and antique furniture of superb\n\ craftsmanship, the parlor reflects its owner's impeccable taste. The tropical\n\ sun is streaming in through open shutters *+. There doesn't seem \n\ to be anybody around. A large immaculate oaken desk is visible in the\n\ study and it even has a old fashioned telephone to complete the decor.**\n", {0} }, /* 191 */ {"You are in a palm grove.", {135, 191, 233, 191, 88, 0, 0, 0}, "Grassy rows of palms stretch as far as I can see.** There is a road +.*\n", {0} }, /* 192 */ {"You are on a dirt road.", {136, 233, 234, 135, 88, 0, 0, 0}, "The road winds through a coconut palm grove here. It continues on - \n\ and -.**\n", {0} }, /* 193 */ {"The road leads to several large buildings here.", {235, 136, 236, 237, 88, 0, 0, 0}, "There is a clubhouse +,* a large barn and stable +, and a garage of \n\ similar construct to the barn +.\n", {0} }, /* 194 */ {"This part of the beach is impassable.", {0, 138, 0, 0, 96, 0, 0, 0}, "The huge rocks and thunderous surf here would pound our frail bodies to pulp\n\ in an instant.* The only direction I'm going is -.**\n", {0} }, /* 195 */ {"You are in the gardens.", {195, 140, 197, 138, 96, 0, 0, 0}, "So much green grass is a pleasure to the eyes.****\n", {0} }, /* 196 */ {"You are in the gardens.", {140, 183, 197, 139, 99, 0, 0, 0}, "Beautiful flowers and shrubs surround a little goldfish pond.****\n", {0} }, /* 197 */ {"You are on a stone walk in the garden.", {195, 196, 238, 140, 99, 0, 0, 0}, "The walk leads to a road **+.*\n", {0} }, /* 198 */ {"You are in the forest near the road.", {198, 141, 216, 198, 73, 0, 0, 0}, "There are many thorny bushes here!****\n", {0} }, /* 199 */ {"You are at a fork in the road.", {239, 146, 141, 170, 73, 0, 0, 0}, "Two roads come together in the forest here. One runs -,* the other \n\ runs - and -.\n", {0} }, /* 200 */ {"You are on a dirt path around the lagoon.", {170, 147, 146, 0, 74, 0, 0, 0}, "The still waters reflect bending palms and a cloudless sky. It looks like\n\ the path runs into a clearing +. The path continues -.**\n", {0} }, /* 201 */ {"You are drowning in the lagoon.", {201, 201, 147, 201, 74, 0, 0, 0}, "I suggest you get out before you become waterlogged.****\n", {0} }, /* 202 */ {"You are in a coconut palm grove.", {202, 148, 203, 204, 77, 0, 0, 0}, "****\n", {0} }, /* 203 */ {"You are in a palm grove.", {202, 149, 205, 148, 77, 0, 0, 0}, "****\n", {0} }, /* 204 */ {"You are in a palm grove.", {202, 150, 148, 206, 77, 0, 0, 0}, "****\n", {0} }, /* 205 */ {"You are on a dirt road.", {203, 155, 212, 149, 77, 0, 0, 0}, "*This road ends here at a palm grove but continues on - for quite\n\ some way.**\n", {0} }, /* 206 */ {"You are in a coconut palm grove.", {204, 156, 150, 213, 77, 0, 0, 0}, "****\n", {0} }, /* 207 */ {"You are in a coconut grove.", {151, 219, 208, 209, 77, 0, 0, 0}, "*The grove ends +.**\n", {0} }, /* 208 */ {"You are in a coconut grove.", {152, 207, 239, 151, 77, 0, 0, 0}, "**There is a dirt road +.*\n", {0} }, /* 209 */ {"You are in a coconut grove.", {153, 207, 151, 211, 77, 0, 0, 0}, "****\n", {0} }, /* 210 */ {"This is a dirt road.", {205, 239, 212, 154, 77, 0, 0, 0}, "The road continues - and -.**\n", {0} }, /* 211 */ {"You are in a coconut grove.", {153, 209, 153, 213, 77, 0, 0, 0}, "****\n", {0} }, /* 212 */ {"You are in the woods near the road.", {205, 210, 212, 155, 77, 0, 0, 0}, "There are many thorny bushes here!****\n", {0} }, /* 213 */ {"You are in a coconut grove.", {213, 213, 156, 234, 88, 0, 0, 0}, "***The grove ends in a clearing +.\n", {0} }, /* 214 */ {"You are walking along some high cliffs.", {162, 0, 0, 159, 86, 0, 0, 0}, "The island bends sharply + here with high cliffs -\n\ and -. The cliffs are lower +.\n", {0} }, /* 215 */ {"You are at the coast road turn around.", {0, 162, 0, 158, 90, 0, 0, 0}, "The coast road ends here in a lookout with a view of 100 kilometers of blue\n\ sea and 100 meters of rugged cliff. Far below the waves crash against rocks.\n\ ****\n", {0} }, /* 216 */ {"You are in the woods near the road.", {216, 163, 216, 198, 79, 0, 257, 0}, "These thorny bushes are killing me.****\n", {0} }, /* 217 */ {"You are in the kitchen.", {0, 0, 0, 165, 0, 0, 0, 0}, "A small gas stove and a refrigerator are all the only appliances here. The\n\ gas oven has been left on and the whole room is reeking with natural gas.\n\ One spark from a match and.... The door out is ***+.\n", {0} }, /* 218 */ {"You are in the bedroom.", {0, 0, 165, 0, 0, 0, 0, 0}, "A soft feather comforter on top of layers of Answer blankets make this a very\n\ luxurious place to sleep indeed. There are also some end tables and a dresser\n\ here.** The living room is +.*\n", {0} }, /* 219 */ {"You are in the woods.", {207, 169, 220, 221, 81, 0, 0, 0}, "There seems to be a clearing +.***\n", {0} }, /* 220 */ {"You are in the woods near the road.", {219, 170, 239, 169, 81, 0, 0, 0}, "*As far as I can tell, there are two roads + and +.*\n", {0} }, /* 221 */ {"You are in the woods.", {207, 171, 219, 222, 81, 0, 0, 0}, "The forest is clearer +.***\n", {0} }, /* 222 */ {"You are on the lagoon's inland finger.", {0, 172, 171, 172, 81, 0, 0, 0}, "It is impossible to follow the lagoon any farther inland because of sharp\n\ and very painful sedges.* The road is +.**\n", {0} }, /* 223 */ {"You are in a grassy coconut grove.", {240, 173, 224, 241, 82, 0, 0, 0}, "The tall palms provide a perfect canopy for the lush green grass.***\n\ There is a road +.\n", {0} }, /* 224 */ {"You are near the lagoon's inland finger.", {0, 174, 0, 173, 82, 0, 0, 0}, "Very sharp sedges make it impossible to follow the lagoon any farther inland.\n\ *There is a road +.**\n", {0} }, /* 225 */ {"You are on a dirt road.", {241, 175, 173, 226, 82, 0, 0, 0}, "The road winds through a coconut grove here and continues - and -.**\n", {0} }, /* 226 */ {"You are in the woods near the road.", {226, 226, 175, 226, 82, 0, 0, 0}, "**The road is +.*\n", {0} }, /* 227 */ {"This is a beach?", {227, 227, 177, 0, 82, 0, 0, 0}, "Hard jagged rocks that pierce with every footstep hardly comprise a beach.**\n\ Let's go -.*\n", {0} }, /* 228 */ {"The trail is lost in the woods here.", {241, 241, 179, 241, 84, 0, 0, 0}, "I suppose the animals that use this trail all depart in different directions\n\ when they get this far into the woods.** The trail goes -.*\n", {0} }, /* 229 */ {"You are on the bank of a stream.", {182, 0, 242, 180, 84, 0, 0, 0}, "The stream falls over several small boulders here and continues on **-.*\n", {0} }, /* 230 */ {"You are just inside the cave.", {181, 267, 0, 0, 0, 0, 0, 0}, "A steamy hot breath is belching from the depths of the earth within.* The\n\ cave continues -.**\n", {0} }, /* 231 */ {"You are just inside the cave entrance.", {274, 0, 0, 0, 0, 0, 0, 0}, "The air is hot and sticky inside. The cave continues -. There is a \n\ stone door in the wall +. A wooden sign in the dust reads in old elven\n\ runes, \"GSRF KDIRE NLVEMP!\".**\n", {0} }, /* 232 */ {"You are at the edge of a huge chasm.", {0, 0, 189, 0, 76, 0, 0, 0}, "Several hundred feet down I can see the glimmer of placid water. The\n\ rivulets drain over the edge and trickle down into the depths. It is \n\ impossible to climb down without a rope.** The canyon continues -.*\n", {0} }, /* 233 */ {"You are on a dirt road.", {192, 241, 240, 191, 88, 0, 0, 0}, "The road winds through a coconut grove here. The road continues on -\n\ and -.**\n", {0} }, /* 234 */ {"You are in a coconut palm grove near the road.", {193, 233, 213, 192, 88, 0, 0, 0}, "***The road is +.\n", {0} }, /* 235 */ {"You are at the clubhouse.", {0, 193, 0, 0, 0, 0, 0, 0}, "The clubhouse is built over the most inland part of the lagoon. Tropical\n\ bananas and fragrant frangipani grow along the grassy shore. Walking across\n\ the short wooden bridge, we enter. Along one wall is a bar with only a few\n\ people seated at it. The restaurant and dance floor are closed off with\n\ a 2 inch nylon rope. ****\n", {0} }, /* 236 */ {"You are in the stables.", {0, 0, 0, 193, 0, 0, 0, 0}, "Neighing horses snacking on hay and oats fill the stalls on both sides of\n\ the barn. It is rather warm in here but that is not the most offensive\n\ part. The old boards of the barn part just enough to let in dust laden\n\ shafts of light. Flies swarm overhead and strafe the ground for dung.\n\ My nose is beginning to itch. ****\n", {0} }, /* 237 */ {"You are in the old garage.", {0, 0, 193, 0, 0, 0, 0, 0}, "This is an old wooden building of the same vintage as the stables. Beneath\n\ a sagging roof stand gardening tools and greasy rags. Parked in the center\n\ is an underpowered Plymouth Volare' with a red and white striped golf cart\n\ roof. ****\n", {0} }, /* 238 */ {"You are on a dirt road.", {197, 197, 243, 197, 85, 0, 0, 0}, "The road leads to a beautiful formal garden laced with stone walks and tropical\n\ flowers and trees.** The road continues -. A walk leads -.\n", {0} }, /* 239 */ {"You are on a dirt road.", {210, 199, 198, 220, 73, 0, 0, 0}, "The road runs - and -.**\n", {0} }, /* 240 */ {"You are in a coconut grove near the road.", {234, 223, 234, 233, 88, 0, 0, 0}, "***The road is +.\n", {0} }, /* 241 */ {"You are on a dirt road.", {233, 225, 223, 226, 82, 0, 0, 0}, "The road continues - and -.**\n", {0} }, /* 242 */ {"The stream plummets over a cliff here.", {182, 0, 0, 229, 84, 0, 0, 0}, "Falling 10 agonizing meters into spray, only droplets of the stream are\n\ left to dance off the floor below. I thought I saw a sparkle of gold\n\ at the bottom of the falls, but now it is gone. There is no way down,\n\ even with a strong rope. ****\n", {0} }, /* 243 */ {"You are on a dirt road.", {0, 0, 244, 238, 85, 0, 0, 0}, "**The road continues - and -.\n", {0} }, /* 244 */ {"You are on a dirt road.", {0, 245, 0, 243, 88, 0, 0, 0}, "*The road continues -* and -.\n", {0} }, /* 245 */ {"You are on a dirt road.", {244, 234, 213, 136, 88, 0, 0, 0}, "The road goes -* and *-.\n", {0} }, /* 246 */ {"You are in a low passage.", {247, 160, 0, 0, 0, 0, 0, 0}, "The passage is partially flooded here and it may be hazardous to proceed.\n\ Water is surging from the tunnel and heading out to sea. Strange moaning\n\ noises rise above the rushing of the water. They are as thin as a whispering\n\ wind yet penetrate to my very soul. I think we have come too far...\n\ The passage continues -.***\n", {0} }, /* 247 */ {"The walls are very close together here.", {248, 0, 0, 0, 0, 0, 0, 0}, "I can barely squeeze through the jagged opening. Slimy sea weeds provide\n\ no footing at all. This tunnel seems to be an ancient lava tube. There is\n\ a large room -.***\n", {0} }, /* 248 */ {"You are in the cathedral room.", {249, 251, 249, 251, 0, 0, 0, 0}, "Your light casts ghostly shadows on the walls but cannot pierce the \n\ engulfing darkness overhead. The sound of water dripping echoes in the void.\n\ *I can see no passages leading out of this room. We have definitely\n\ come too far.*** \n", {0} }, /* 249 */ {"You are walking through a very round tunnel.", {252, 0, 0, 0, 252, 1, 0, 0}, "The round walls of this tunnel are amazingly smooth to the touch. A little\n\ trickle of water flows down the center. The tunnel climbs steadily +.\n\ The cave is beginning to flood again! Let's get out of here! ***\n", {0} }, /* 250 */ {"You are in the cathedral anteroom.", {0, 0, 0, 248, 253, 1, 0, 0}, "This small chamber with a flat stone floor is to one side of the cathedral \n\ room. We appear to be at the bottom of a tall narrow shaft. There are many \n\ puddles of water here. A staircase hewn from solid rock and black lava \n\ leads up.*** The cathedral room is +.\n", {0} }, /* 251 */ {"You are in a wide chamber.", {0, 0, 248, 254, 0, 0, 0, 0}, "Water is sprinkling from the ceiling here. A shallow pool populated by a \n\ myriad of blind white creatures sparkles in your light. Tiny shrimp and\n\ crabs scurry away, frightened by the blinding rays.** The cave \n\ continues - and -.\n", {0} }, /* 252 */ {"You are at the top of a sloping passage.", {0, 0, 255, 256, 257, 1, 0, 0}, "There is much algae growing here, both green and brown specimens. \n\ Water from an underground sea surges and splashes against the slope of\n\ the rock. The walls glisten with shiny minerals. High above, light\n\ filters in through a narrow shaft.** A hallway here runs -\n\ and -.\n", {0} }, /* 253 */ {"You are in an elaborately tiled room.", {0, 0, 258, 0, 0, 0, 250, 0}, "Large colorful tiles plate the floor and walls. The ceiling is a mosaic\n\ of gems set in gold. Hopefully it is only our footsteps that are echoing in\n\ this hollow chamber.** The room continues -. A stone staircase\n\ leads down.*\n", {0} }, /* 254 */ {"You are at a dead end.", {0, 0, 251, 0, 0, 0, 0, 0}, "The walls here are alive with dark mussels. They click their shells menacingly\n\ if we disturb them. ** The only exit is +.*\n", {0} }, /* 255 */ {"The tunnel is very low here.", {0, 0, 259, 252, 0, 0, 0, 0}, "I practically have to crawl on my knees to pass through this opening. The\n\ air is stiflingly damp, but I can't hear any sounds of water dripping.**\n\ The crawlspace continues -. The tunnel seems wider +.\n", {0} }, /* 256 */ {"This is the supply room.", {0, 0, 252, 0, 0, 0, 0, 0}, "Picks and shovels line the walls here, as well as hard hats, boxes of\n\ dynamite, and a cartload of very high grade gold and silver ore.** \n\ A tunnel leads off +.*\n", {0} }, /* 257 */ {"You have found a secret entrance to the catacombs.", {0, 0, 0, 0, 216, 1, 252, 0}, "I have a sickening feeling that we should not have entered the catacombs.\n\ Below is a wet, seaweed covered floor. Above is a way out. ****\n", {0} }, /* 258 */ {"You are in the catacombs.", {0, 0, 260, 253, 0, 0, 0, 0}, "Ornate tombs and piles of treasure line the walls. Long spears with many\n\ blades, fine swords and coats of mail, heaps of coins, jewelry, pottery, \n\ and golden statues are tribute of past kings and queens.** The catacombs\n\ continue - and -.\n", {0} }, /* 259 */ {"You are crawling on your stomach.", {0, 0, 261, 255, 0, 0, 0, 0}, "The passage is quite narrow and jagged, but the rock is no longer lava.\n\ It appears to be a form of granite.** The crawlspace continues -, \n\ but I would just as soon go -.\n", {0} }, /* 260 */ {"You are in the Sepulcher.", {0, 0, 0, 258, 0, 0, 0, 0}, "A single tomb is here. Encrusted with diamonds and opals, and secured with \n\ straps of a very hard, untarnished silver, this tomb must be of a great king.\n\ Vases overflowing with gold coins stand nearby. A line of verse on the wall\n\ reads, \"Three he made and gave them to his daughters.\"****\n", {0} }, /* 261 */ {"The passage is wider here.", {0, 0, 0, 259, 0, 0, 0, 0}, "You are at the top of a flooded shaft. About a meter below the edge,\n\ dark water rises and falls to the rhythm of the sea. A ladder goes\n\ down into water here.*** A small crawlspace goes -.\n", {0} }, /* 262 */ {"You are at the bottom of a ladder.", {0, 0, 0, 0, 261, 1, 263, 0}, "This is a narrow platform to rest on before we continue either up or down this\n\ rickety wooden ladder.****\n", {0} }, /* 263 */ {"You are standing in several inches of water.", {264, 0, 265, 266, 262, 1, 0, 0}, "This seems to be a working mine. Many different tunnels wander off following\n\ glowing veins of precious metal. The floor is flooded here since we must\n\ be nearly at sea level. A ladder leads up. ****\n", {0} }, /* 264 */ {"The tunnel here is blocked by broken rocks.", {0, 263, 0, 0, 0, 0, 0, 0}, "The way is blocked, but if you had some dynamite, we might be able to blast our\n\ way through.* The passage goes -.**\n", {0} }, /* 265 */ {"The tunnel is too flooded to proceed.", {0, 0, 0, 263, 0, 0, 0, 0}, "Hidden shafts could swallow us if we tried to continue on down this tunnel.\n\ The flooding is already up to my waist. Large crystals overhead shimmer\n\ rainbows of reflected light.*** Let's go -.\n", {0} }, /* 266 */ {"The mine is less flooded here.", {0, 0, 263, 0, 0, 0, 0, 0}, "A meandering gold laden vein of quartz and blooming crystals of diamonds\n\ and topaz burst from the walls of the cave. A passage goes -.***\n", {0} }, /* 267 */ {"You are inside the cave.", {230, 268, 0, 0, 0, 0, 0, 0}, "A hot steam swirls around our heads, and the walls are warm to the touch.\n\ The trail winds + and +.**\n", {0} }, /* 268 */ {"You are in a rather large chamber.", {267, 0, 0, 269, 0, 0, 269, 0}, "Beds of ferns and palm leaves make several cozy nests along the walls. In the\n\ center of the room is a throne of gold and silver which pulls out into a bed\n\ of enormous size.*** A passageway - leads down.\n", {0} }, /* 269 */ {"You are walking along the edge of a huge abyss.", {0, 0, 268, 0, 268, 1, 270, 0}, "Steam is rising in great clouds from the immeasurable depths. A very narrow\n\ trail winds down.** There is a tunnel +.*\n", {0} }, /* 270 */ {"You are on the edge of a huge abyss.", {0, 0, 0, 0, 269, 1, 271, 0}, "The trail winds farther down.****\n", {0} }, /* 271 */ {"You are winding your way along the abyss.", {0, 0, 0, 0, 270, 1, 272, 0}, "The trail continues up and down.****\n", {0} }, /* 272 */ {"You are on a wide shelf near the steamy abyss.", {0, 273, 0, 0, 271, 1, 0, 0}, "The stifling hot cave seems even hotter to me, staring down into this misty \n\ abyss. A trail winds up.* A passageway leads -.**\n", {0} }, /* 273 */ {"You are in a wide tunnel leading to a fuming abyss.", {272, 274, 0, 0, 0, 0, 0, 0}, "The passageway winds through many beautiful formations of crystals and\n\ sparkling minerals. The tunnel continues - and -.**\n", {0} }, /* 274 */ {"You are in a tunnel.", {273, 231, 0, 0, 0, 0, 0, 0}, "It is very warm in here. The smell of steam and hot rocks permeates the place.\n\ The cave continues - and -.**\n", {0} }, /* 275 */ {"You are at the bottom of a pit.", {0, 0, 0, 0, 232, 0, 0, 0}, "I can see daylight far up at the mouth of the pit. A cool draft wafts down.\n\ There doesn't seem to be any way out, and I don't remember how we came in.\n\ If you had a rope it might be possible to climb out. ****\n", {0} }, }; bsd-games-2.17/battlestar/getcom.c0000664000175000017500000000660610155330535015576 0ustar jsm28jsm28/* $NetBSD: getcom.c,v 1.12 2004/11/05 21:30:31 dsl Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: getcom.c,v 1.12 2004/11/05 21:30:31 dsl Exp $"); #endif #endif /* not lint */ #include "extern.h" char * getcom(buf, size, prompt, error) char *buf; int size; const char *prompt, *error; { for (;;) { fputs(prompt, stdout); if (fgets(buf, size, stdin) == 0) { if (feof(stdin)) die(); clearerr(stdin); continue; } while (isspace((unsigned char)*buf)) buf++; if (*buf) break; if (error) puts(error); } /* If we didn't get to the end of the line, don't read it in next time. */ if (buf[strlen(buf) - 1] != '\n') { int i; while ((i = getchar()) != '\n' && i != EOF) continue; } return (buf); } /* * shifts to UPPERCASE if flag > 0, lowercase if flag < 0, * and leaves it unchanged if flag = 0 */ char * getword(buf1, buf2, flag) char *buf1, *buf2; int flag; { int cnt; cnt = 1; while (isspace((unsigned char)*buf1)) buf1++; if (*buf1 != ',') { if (!*buf1) { *buf2 = 0; return (0); } while (cnt < WORDLEN && *buf1 && !isspace((unsigned char)*buf1) && *buf1 != ',') if (flag < 0) { if (isupper((unsigned char)*buf1)) { *buf2++ = tolower((unsigned char)*buf1++); cnt++; } else { *buf2++ = *buf1++; cnt++; } } else if (flag > 0) { if (islower((unsigned char)*buf1)) { *buf2++ = toupper((unsigned char)*buf1++); cnt++; } else { *buf2++ = *buf1++; cnt++; } } else { *buf2++ = *buf1++; cnt++; } if (cnt == WORDLEN) while (*buf1 && !isspace((unsigned char)*buf1)) buf1++; } else *buf2++ = *buf1++; *buf2 = '\0'; while (isspace((unsigned char)*buf1)) buf1++; return (*buf1 ? buf1 : NULL); } bsd-games-2.17/battlestar/globals.c0000664000175000017500000002162207767741711015757 0ustar jsm28jsm28/* $NetBSD: globals.c,v 1.19 2003/08/07 09:37:02 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: globals.c,v 1.19 2003/08/07 09:37:02 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" int WEIGHT = MAXWEIGHT; int CUMBER = MAXCUMBER; const char *const objdes[NUMOFOBJECTS] = { "There is a knife here.", "There are an exquisitely crafted sword and scabbard here.", NULL, /* Can land from here. */ "There is a fierce woodsman here brandishing a heavy mallet.", "There is an unwieldy two-handed sword here.", "There is a bloody meat cleaver here.", "A rusty broadsword is lying here.", "There is an ancient coat of finely woven mail here.", "There is a old dented helmet with an ostrich plume here.", "There is a shield of some native tribe here.", "The maid's body is lying here. She was murdered!", "There is a Viper ready for launch here.", "A kerosene lantern is burning luridly here.", "An old pair of shoes has been discarded here.", NULL, /* Cylon. */ "There is a pair of pajamas here.", "A kingly robe of royal purple and spun gold is draped here.", "There is a strange golden amulet on the floor here.", "A medallion of solid gold shimmers on the ground nearby.", "A talisman of gold is lying here.", "A dead woodsman has fallen here. He was savagely murdered.", "A heavy wooden mallet lies nearby.", "There is a laser pistol here.", "A flower-like young goddess is bathing in the hot mineral pools. She is \nwatching you, but continues to steep and sing softly.", "The goddess is reclining on a bed of ferns and studying you intently.", "There is a grenade here.", "There is a length of heavy chain here.", "There is a stout rope here.", "There is a pair of Levi's here.", "A bloody mace is lying on the ground here.", "There is a shovel here.", "A long, sharp halberd is propped up here.", "There is a compass here.", "Wreckage and smoldering debris from a crash litter the ground here.", "A woodland Elf armed with a shield and deadly halberd lunges toward you!", "I think I hear footsteps behind us.", "There are a few coins here.", "There are some matches here.", "An unctuous man in a white suit and a dwarf are standing here.", "There are some ripe papayas here.", "There is a ripe pineapple here.", "There are some kiwi fruit here.", "There are some coconuts here.", "There is a ripe mango here.", "There is a sparkling diamond ring here.", "There is a colorful pink potion in a small crystal vial here.", "A gold bracelet is on the ground here.", "A swarthy woman with stern features pulls you aside from the crowd,\n'I must talk to you -- but not here. Meet me at midnight in the gardens.'", "The swarthy woman has been awaiting you anxiously. 'I must warn you that the\nIsland has anticipated your Quest. You will not be welcomed. The Darkness is\nstrong where you must search. Seek not the shadows save only at night, for\nthen are they the weakest. In the mountains far from here a canyon winds\nwith ferns and streams and forgotten vines. There you must go. Take this\nrope.'", "Out from the shadows a figure leaps! His black cape swirls around, and he\nholds a laser sword at your chest. 'So, you have come to fulfill the Quest.\nHa! Your weapons are no match for me!'", "An old-timer with one eye missing and no money for a drink sits at the bar.", "You are flying through an asteroid field!", "A planet is nearby.", "The ground is charred here.", "There is a thermonuclear warhead here.", "The fragile, beautiful young goddess lies here. You murdered her horribly.", "The old-timer is lying here. He is dead.", "The native girl's body is lying here.", "A native girl is sitting here.", "A gorgeous white stallion is standing here.", "The keys are in the ignition.", "A pot of pearls and jewels is sitting here.", "A bar of solid gold is here.", "There is a 10 kilogram diamond block here." }; const char *const objsht[NUMOFOBJECTS] = { "knife", "fine sword", NULL, /* Can land from here. */ "Woodsman", "two-handed sword", "meat cleaver", "broadsword", "coat of mail", "plumed helmet", "shield", "maid's body", "viper", "lantern", "shoes", NULL, /* Cylon. */ "pajamas", "robe", "amulet", "medallion", "talisman", "woodsman's body", "wooden mallet", "laser", NULL, /* Bathing goddess. */ NULL, /* Goddess. */ "grenade", "chain", "rope", "levis", "mace", "shovel", "halberd", "compass", NULL, /* Crash debris. */ "Elf", NULL, /* Footsteps. */ "coins", "match book", NULL, /* Man and dwarf. */ "papayas", "pineapple", "kiwi", "coconuts", "mango", "ring", "potion", "bracelet", NULL, /* Swarthy woman. */ NULL, /* Swarthy woman (with message). */ "Dark Lord", NULL, /* Old-timer. */ NULL, /* Asteroid field. */ NULL, /* Planet nearby. */ NULL, /* Charred ground. */ "warhead", "goddess's body", "old-timer's body", "girl's body", NULL, /* Native girl. */ "stallion", "car", "pot of jewels", "bar of gold", "diamond block" }; const char *const ouch[NUMOFINJURIES] = { "some minor abrasions", "some minor lacerations", "a minor puncture wound", "a minor amputation", "a sprained wrist", "a fractured ankle and shattered kneecap", "a broken arm and dislocated shoulder", "a few broken ribs", "a broken leg and torn ligaments", "a broken back and ruptured spleen", "some deep incisions and a loss of blood", "a fractured skull and mashed face", "a broken neck" }; const int objwt[NUMOFOBJECTS] = { 1, 5, 0, 10, 15, 2, 10, 10, 3, 5, 50, 2500, 2, 1, 100, 1, 2, 1, 1, 1, 60, 10, 5, 0, 50, 5, 15, 5, 1, 20, 10, 10, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 55, 47, 50, 45, 45, 100, 2000, 30, 20, 10 }; const int objcumber[NUMOFOBJECTS] = { 1, 5, 0, 150, 10, 1, 5, 2, 2, 1, 5, 10, 1, 1, 10, 1, 1, 1, 1, 1, 7, 5, 4, 0, 0, 1, 1, 1, 1, 5, 4, 4, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 3, 1, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 7, 8, 10, 8, 8, 10, 10, 3, 1, 2 }; const int objflags[NUMOFOBJECTS] = { 0, 0, OBJ_NONOBJ, OBJ_PERSON, 0, 0, 0, 0, 0, 0, 0, 0, 0, OBJ_PLURAL, OBJ_NONOBJ, OBJ_PLURAL, 0, OBJ_AN, 0, 0, 0, 0, 0, OBJ_PERSON, OBJ_PERSON, 0, 0, 0, OBJ_PLURAL, 0, 0, 0, 0, 0, OBJ_AN|OBJ_PERSON, OBJ_NONOBJ, OBJ_PLURAL, 0, OBJ_PERSON, OBJ_PLURAL, 0, 0, OBJ_PLURAL, 0, 0, 0, 0, OBJ_PERSON, OBJ_PERSON, OBJ_PERSON, OBJ_PERSON, OBJ_NONOBJ, OBJ_NONOBJ, OBJ_NONOBJ, 0, 0, OBJ_AN, 0, OBJ_PERSON, 0, 0, 0, 0, 0 }; int win = 1; int matchcount = 20; int followgod = -1; int followfight = -1; struct room *location; /* current input line */ char words[NWORD][WORDLEN]; int wordvalue[NWORD]; int wordtype[NWORD]; int wordcount, wordnumber; /* state of the game */ int ourtime; int position; int direction; int left, right, ahead, back; int fuel, torps; int carrying, encumber; int rythmn; int ate; int snooze; int meetgirl; int godready; int wintime; int wiz; int tempwiz; int matchlight; int loved; int pleasure, power, ego; int notes[NUMOFNOTES]; unsigned int inven[NUMOFWORDS]; unsigned int wear[NUMOFWORDS]; char beenthere[NUMOFROOMS + 1]; char injuries[NUMOFINJURIES]; int verbose = 0; const char *username; bsd-games-2.17/battlestar/nightobjs.c0000664000175000017500000000543407767741711016326 0ustar jsm28jsm28/* $NetBSD: nightobjs.c,v 1.9 2003/08/07 09:37:03 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)nightobjs.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: nightobjs.c,v 1.9 2003/08/07 09:37:03 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" const struct objs nightobjs[] = { {218, PAJAMAS}, {235, NATIVE}, {92, PAPAYAS}, {92, PINEAPPLE}, {92, KIWI}, {92, MANGO}, {92, NATIVE}, {92, MAN}, {181, LAMPON}, {236, LAMPON}, {92, LAMPON}, {216, WOODSMAN}, {216, DEADWOOD}, {216, MALLET}, {168, WOODSMAN}, {168, DEADWOOD}, {168, MALLET}, {170, WOODSMAN}, {170, DEADWOOD}, {170, MALLET}, {124, SHIELD}, {124, HALBERD}, {124, ELF}, {144, SHIELD}, {144, HALBERD}, {144, ELF}, {113, SHIELD}, {113, HALBERD}, {113, ELF}, {161, SHIELD}, {161, HALBERD}, {161, ELF}, {169, SHIELD}, {169, HALBERD}, {169, ELF}, {182, SHIELD}, {182, HALBERD}, {182, ELF}, {198, SHIELD}, {198, HALBERD}, {198, ELF}, {212, SHIELD}, {212, HALBERD}, {212, ELF}, {216, SHIELD}, {216, HALBERD}, {216, ELF}, {226, SHIELD}, {226, HALBERD}, {226, ELF}, {228, SHIELD}, {228, HALBERD}, {228, ELF}, {68, CYLON}, {144, SHOVEL}, {249, FOOT}, {250, FOOT}, {93, PAPAYAS}, {0, 0} }; bsd-games-2.17/battlestar/battlestar.60000664000175000017500000001250607767741711016425 0ustar jsm28jsm28.\" $NetBSD: battlestar.6,v 1.14 2003/08/07 09:37:00 agc Exp $ .\" .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)battlestar.6 8.1 (Berkeley) 5/31/93 .\" .Dd September 7, 2000 .Dt BATTLESTAR 6 .Os .Sh NAME .Nm battlestar .Nd a tropical adventure game .Sh SYNOPSIS .Nm .Op Fl r .Op Ar saved-file .Sh DESCRIPTION .Nm is an adventure game in the classic style. However, it's slightly less of a puzzle and more a game of exploration. There are a few magical words in the game, but on the whole, simple English should suffice to make one's desires understandable to the parser. .Sh THE SETTING In the days before the darkness came, when battlestars ruled the heavens... .Bd -literal -offset indent Three He made and gave them to His daughters, Beautiful nymphs, the goddesses of the waters. One to bring good luck and simple feats of wonder, Two to wash the lands and churn the waves asunder, Three to rule the world and purge the skies with thunder. .Ed .Pp In those times great wizards were known and their powers were beyond belief. They could take any object from thin air, and, uttering the word .Sq su could disappear. .Pp In those times men were known for their lust for gold and desire to wear fine weapons. Swords and coats of mail were fashioned that could withstand a laser blast. .Pp But when the darkness fell, the rightful reigns were toppled. Swords and helms and heads of state went rolling across the grass. The entire fleet of battlestars was reduced to a single ship. .Sh SAMPLE COMMANDS .Bd -literal -offset indent take --- take an object drop --- drop an object wear --- wear an object you are holding draw --- carry an object you are wearing put on --- take an object and wear it take off -- draw an object and drop it throw \*[Lt]object\*[Gt] \*[Lt]direction\*[Gt] ! \*[Lt]shell esc\*[Gt] .Ed .Sh IMPLIED OBJECTS .Bd -literal -offset indent \*[Gt]-: take watermelon watermelon: Taken. \*[Gt]-: eat watermelon: Eaten. \*[Gt]-: take knife and sword and apple, drop all knife: Taken. broadsword: Taken. apple: Taken. knife: Dropped. broadsword: Dropped. apple: Dropped. \*[Gt]-: get knife: Taken. .Ed .Pp Notice that the "shadow" of the next word stays around if you want to take advantage of it. That is, saying "take knife" and then "drop" will drop the knife you just took. .Sh SCORE \*[Am] INVEN The two commands .Dq score and .Dq inven will print out your current status in the game. .Sh SAVING A GAME The command .Dq save will save your game in a file called .Pa .Bstar in your home directory by default. You can recover a saved game by using the .Fl r option when you start up the game, or by giving the name of the saved file as an argument. Save files will be saved to and restored from your home directory unless a path is specified - i.e., .Dq Li battlestar -r savedgame will look for .Pa savedgame in your home directory, but .Dq Li battlestar -r ./savedgame will look in the current directory. .Dq Li battlestar -r will look for the default file, .Pa .Bstar in your home directory. .Sh DIRECTIONS The compass directions N, S, E, and W can be used if you have a compass. If you don't have a compass, you'll have to say R, L, A, or B, which stand for Right, Left, Ahead, and Back. Directions printed in room descriptions are always printed in R, L, A, and B relative directions. .Sh HISTORY I wrote Battlestar in 1979 in order to experiment with the niceties of the C Language. Most interesting things that happen in the game are hardwired into the code, so don't send me any hate mail about it! Instead, enjoy art for art's sake! .Sh AUTHOR .An David Riggle .Sh INSPIRATION \*[Am] ASSISTANCE .Bl -item -compact .It Chris Guthrie .It Peter Da Silva .It Kevin Brown .It Edward Wang .It Ken Arnold \*[Am] Company .El .Sh BUGS Countless. .Sh FAN MAIL Send to edward%ucbarpa@berkeley.arpa, chris%ucbcory@berkeley.arpa, riggle.pa@xerox.arpa. bsd-games-2.17/battlestar/fly.c0000664000175000017500000001361210005547567015116 0ustar jsm28jsm28/* $NetBSD: fly.c,v 1.12 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)fly.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: fly.c,v 1.12 2004/01/27 20:30:29 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" #undef UP #include #define MIDR (LINES/2 - 1) #define MIDC (COLS/2 - 1) static int row, column; static int dr = 0, dc = 0; static char destroyed; int ourclock = 120; /* time for all the flights in the game */ static char cross = 0; static sig_t oldsig; static void blast(void); static void endfly(void); static void moveenemy(int); static void notarget(void); static void screen(void); static void succumb(int); static void target(void); static void succumb(dummy) int dummy __attribute__((__unused__)); { if (oldsig == SIG_DFL) { endfly(); exit(1); } if (oldsig != SIG_IGN) { endfly(); (*oldsig) (SIGINT); } } int visual() { destroyed = 0; if (initscr() == NULL) { puts("Whoops! No more memory..."); return (0); } oldsig = signal(SIGINT, succumb); cbreak(); noecho(); screen(); row = rnd(LINES - 3) + 1; column = rnd(COLS - 2) + 1; moveenemy(0); for (;;) { switch (getchar()) { case 'h': case 'r': dc = -1; fuel--; break; case 'H': case 'R': dc = -5; fuel -= 10; break; case 'l': dc = 1; fuel--; break; case 'L': dc = 5; fuel -= 10; break; case 'j': case 'u': dr = 1; fuel--; break; case 'J': case 'U': dr = 5; fuel -= 10; break; case 'k': case 'd': dr = -1; fuel--; break; case 'K': case 'D': dr = -5; fuel -= 10; break; case '+': if (cross) { cross = 0; notarget(); } else cross = 1; break; case ' ': case 'f': if (torps) { torps -= 2; blast(); if (row == MIDR && column - MIDC < 2 && MIDC - column < 2) { destroyed = 1; alarm(0); } } else mvaddstr(0, 0, "*** Out of torpedoes. ***"); break; case 'q': endfly(); return (0); default: mvaddstr(0, 26, "Commands = r,R,l,L,u,U,d,D,f,+,q"); continue; case EOF: break; } if (destroyed) { endfly(); return (1); } if (ourclock <= 0) { endfly(); die(); } } } static void screen() { int r, c, n; int i; clear(); i = rnd(100); for (n = 0; n < i; n++) { r = rnd(LINES - 3) + 1; c = rnd(COLS); mvaddch(r, c, '.'); } mvaddstr(LINES - 1 - 1, 21, "TORPEDOES FUEL TIME"); refresh(); } static void target() { int n; move(MIDR, MIDC - 10); addstr("------- + -------"); for (n = MIDR - 4; n < MIDR - 1; n++) { mvaddch(n, MIDC, '|'); mvaddch(n + 6, MIDC, '|'); } } static void notarget() { int n; move(MIDR, MIDC - 10); addstr(" "); for (n = MIDR - 4; n < MIDR - 1; n++) { mvaddch(n, MIDC, ' '); mvaddch(n + 6, MIDC, ' '); } } static void blast() { int n; alarm(0); move(LINES - 1, 24); printw("%3d", torps); for (n = LINES - 1 - 2; n >= MIDR + 1; n--) { mvaddch(n, MIDC + MIDR - n, '/'); mvaddch(n, MIDC - MIDR + n, '\\'); refresh(); } mvaddch(MIDR, MIDC, '*'); for (n = LINES - 1 - 2; n >= MIDR + 1; n--) { mvaddch(n, MIDC + MIDR - n, ' '); mvaddch(n, MIDC - MIDR + n, ' '); refresh(); } alarm(1); } static void moveenemy(dummy) int dummy __attribute__((__unused__)); { double d; int oldr, oldc; oldr = row; oldc = column; if (fuel > 0) { if (row + dr <= LINES - 3 && row + dr > 0) row += dr; if (column + dc < COLS - 1 && column + dc > 0) column += dc; } else if (fuel < 0) { fuel = 0; mvaddstr(0, 60, "*** Out of fuel ***"); } d = (double) ((row - MIDR) * (row - MIDR) + (column - MIDC) * (column - MIDC)); if (d < 16) { row += (rnd(9) - 4) % (4 - abs(row - MIDR)); column += (rnd(9) - 4) % (4 - abs(column - MIDC)); } ourclock--; mvaddstr(oldr, oldc - 1, " "); if (cross) target(); mvaddstr(row, column - 1, "/-\\"); move(LINES - 1, 24); printw("%3d", torps); move(LINES - 1, 42); printw("%3d", fuel); move(LINES - 1, 57); printw("%3d", ourclock); refresh(); signal(SIGALRM, moveenemy); alarm(1); } static void endfly() { alarm(0); signal(SIGALRM, SIG_DFL); mvcur(0, COLS - 1, LINES - 1, 0); endwin(); setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Needed for ncurses */ signal(SIGTSTP, SIG_DFL); signal(SIGINT, oldsig); } bsd-games-2.17/battlestar/cypher.c0000664000175000017500000003213507767741711015627 0ustar jsm28jsm28/* $NetBSD: cypher.c,v 1.22 2003/08/07 09:37:01 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: cypher.c,v 1.22 2003/08/07 09:37:01 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" int cypher() { int n; int junk; int lflag = -1; char buffer[10]; char *filename, *rfilename; size_t filename_len; while (wordnumber <= wordcount) { if (wordtype[wordnumber] != VERB && !(wordtype[wordnumber] == OBJECT && wordvalue[wordnumber] == KNIFE)) { printf("%s: How's that?\n", (wordnumber == wordcount) ? words[0] : words[wordnumber]); return (-1); } switch (wordvalue[wordnumber]) { case AUXVERB: /* * Take the following word as the verb (e.g. * "make love", "climb up"). */ wordnumber++; continue; case UP: if (location[position].access || wiz || tempwiz) { if (!location[position].access) puts("Zap! A gust of wind lifts you up."); if (!moveplayer(location[position].up, AHEAD)) return (-1); } else { puts("There is no way up."); return (-1); } lflag = 0; break; case DOWN: if (!moveplayer(location[position].down, AHEAD)) return (-1); lflag = 0; break; case LEFT: if (!moveplayer(left, LEFT)) return (-1); lflag = 0; break; case RIGHT: if (!moveplayer(right, RIGHT)) return (-1); lflag = 0; break; case AHEAD: if (!moveplayer(ahead, AHEAD)) return (-1); lflag = 0; break; case BACK: if (!moveplayer(back, BACK)) return (-1); lflag = 0; break; case SHOOT: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(location[position].objects, n) && objsht[n]) { things++; wordvalue[wordnumber + 1] = n; wordnumber = shoot(); } if (!things) puts("Nothing to shoot at!"); wordnumber++; wordnumber++; } else shoot(); break; case TAKE: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(location[position].objects, n) && objsht[n]) { things++; wordvalue[wordnumber + 1] = n; /* Some objects (type NOUNS) * have special treatment in * take(). For these we * must set the type to NOUNS. * However for SWORD and BODY * all it does is find which * of many objects is meant, * so we need do nothing here. * BATHGOD must become * NORMGOD as well. NOUNS * with no special case * must be included here to * get the right error. DOOR * cannot occur as an object * so need not be included. */ switch(n) { case BATHGOD: wordvalue[wordnumber + 1] = NORMGOD; /* FALLTHROUGH */ case NORMGOD: case AMULET: case MEDALION: case TALISMAN: case MAN: case TIMER: case NATIVE: wordtype[wordnumber + 1] = NOUNS; break; default: wordtype[wordnumber + 1] = OBJECT; } wordnumber = take(location[position].objects); } wordnumber++; wordnumber++; if (!things) puts("Nothing to take!"); } else take(location[position].objects); break; case DROP: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) { things++; wordvalue[wordnumber + 1] = n; wordnumber = drop("Dropped"); } wordnumber++; wordnumber++; if (!things) puts("Nothing to drop!"); } else drop("Dropped"); break; case KICK: case THROW: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things, wv; things = 0; wv = wordvalue[wordnumber]; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n) || (testbit(location[position].objects, n) && objsht[n])) { things++; wordvalue[wordnumber + 1] = n; wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown"); } wordnumber += 2; if (!things) printf("Nothing to %s!\n", wv == KICK ? "kick" : "throw"); } else throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown"); break; case TAKEOFF: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(wear, n)) { things++; wordvalue[wordnumber + 1] = n; wordnumber = takeoff(); } wordnumber += 2; if (!things) puts("Nothing to take off!"); } else takeoff(); break; case DRAW: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(wear, n)) { things++; wordvalue[wordnumber + 1] = n; wordnumber = draw(); } wordnumber += 2; if (!things) puts("Nothing to draw!"); } else draw(); break; case PUTON: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(location[position].objects, n) && objsht[n]) { things++; wordvalue[wordnumber + 1] = n; wordnumber = puton(); } wordnumber += 2; if (!things) puts("Nothing to put on!"); } else puton(); break; case WEARIT: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) { things++; wordvalue[wordnumber + 1] = n; wordnumber = wearit(); } wordnumber += 2; if (!things) puts("Nothing to wear!"); } else wearit(); break; case EAT: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) { things++; wordvalue[wordnumber + 1] = n; wordnumber = eat(); } wordnumber += 2; if (!things) puts("Nothing to eat!"); } else eat(); break; case PUT: put(); break; case INVEN: if (ucard(inven)) { puts("You are holding:\n"); for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) printf("\t%s\n", objsht[n]); if (WEIGHT == 0) printf("\n= %d kilogram%s (can't lift any weight%s)\n", carrying, (carrying == 1 ? "." : "s."), (carrying ? " or move with what you have" : "")); else printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."), carrying * 100 / WEIGHT); if (CUMBER == 0) printf("Your arms can't pick anything up.\n"); else printf("Your arms are %d%% full.\n", encumber * 100 / CUMBER); } else puts("You aren't carrying anything."); if (ucard(wear)) { puts("\nYou are wearing:\n"); for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(wear, n)) printf("\t%s\n", objsht[n]); } else puts("\nYou are stark naked."); if (card(injuries, NUMOFINJURIES)) { puts("\nYou have suffered:\n"); for (n = 0; n < NUMOFINJURIES; n++) if (injuries[n]) printf("\t%s\n", ouch[n]); printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT, (WEIGHT == 1 ? "." : "s.")); } else puts("\nYou are in perfect health."); wordnumber++; break; case USE: lflag = use(); break; case OPEN: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { int things; things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) { things++; wordvalue[wordnumber + 1] = n; dooropen(); } wordnumber += 2; if (!things) puts("Nothing to open!"); } else dooropen(); break; case LOOK: if (!notes[CANTSEE] || testbit(inven, LAMPON) || testbit(location[position].objects, LAMPON) || matchlight) { beenthere[position] = 2; writedes(); printobjs(); if (matchlight) { puts("\nYour match splutters out."); matchlight = 0; } } else puts("I can't see anything."); return (-1); break; case SU: if (wiz || tempwiz) { printf("\nRoom (was %d) = ", position); fgets(buffer, 10, stdin); if (*buffer != '\n') sscanf(buffer, "%d", &position); printf("Time (was %d) = ", ourtime); fgets(buffer, 10, stdin); if (*buffer != '\n') sscanf(buffer, "%d", &ourtime); printf("Fuel (was %d) = ", fuel); fgets(buffer, 10, stdin); if (*buffer != '\n') sscanf(buffer, "%d", &fuel); printf("Torps (was %d) = ", torps); fgets(buffer, 10, stdin); if (*buffer != '\n') sscanf(buffer, "%d", &torps); printf("CUMBER (was %d) = ", CUMBER); fgets(buffer, 10, stdin); if (*buffer != '\n') sscanf(buffer, "%d", &CUMBER); printf("WEIGHT (was %d) = ", WEIGHT); fgets(buffer, 10, stdin); if (*buffer != '\n') sscanf(buffer, "%d", &WEIGHT); printf("Clock (was %d) = ", ourclock); fgets(buffer, 10, stdin); if (*buffer != '\n') sscanf(buffer, "%d", &ourclock); printf("Wizard (was %d, %d) = ", wiz, tempwiz); fgets(buffer, 10, stdin); if (*buffer != '\n') { sscanf(buffer, "%d", &junk); if (!junk) tempwiz = wiz = 0; } printf("\nDONE.\n"); return (0); } else puts("You aren't a wizard."); break; case SCORE: printf("\tPLEASURE\tPOWER\t\tEGO\n"); printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure, power, ego); printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime); printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere, NUMOFROOMS), NUMOFROOMS, card(beenthere, NUMOFROOMS) * 100 / NUMOFROOMS); break; case KNIFE: case KILL: murder(); break; case UNDRESS: case RAVAGE: ravage(); break; case SAVE: printf("\nSave file name (default %s): ", DEFAULT_SAVE_FILE); filename = fgetln(stdin, &filename_len); if (filename_len == 0 || (filename_len == 1 && filename[0] == '\n')) rfilename = save_file_name(DEFAULT_SAVE_FILE, strlen(DEFAULT_SAVE_FILE)); else { if (filename[filename_len - 1] == '\n') filename_len--; rfilename = save_file_name(filename, filename_len); } save(rfilename); free(rfilename); break; case VERBOSE: verbose = 1; printf("[Maximum verbosity]\n"); break; case BRIEF: verbose = 0; printf("[Standard verbosity]\n"); break; case FOLLOW: lflag = follow(); break; case GIVE: give(); break; case KISS: kiss(); break; case LOVE: love(); break; case RIDE: lflag = ride(); break; case DRIVE: lflag = drive(); break; case LIGHT: light(); break; case LAUNCH: if (!launch()) return (-1); else lflag = 0; break; case LANDIT: if (!land()) return (-1); else lflag = 0; break; case TIME: chime(); break; case SLEEP: zzz(); break; case DIG: dig(); break; case JUMP: lflag = jump(); break; case BURY: bury(); break; case SWIM: puts("Surf's up!"); break; case DRINK: drink(); break; case QUIT: die(); default: puts("How's that?"); return (-1); break; } if (wordnumber < wordcount && *words[wordnumber++] == ',') continue; else return (lflag); } return (lflag); } bsd-games-2.17/battlestar/dayobjs.c0000664000175000017500000000642207767741711015770 0ustar jsm28jsm28/* $NetBSD: dayobjs.c,v 1.9 2003/08/07 09:37:01 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)dayobjs.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: dayobjs.c,v 1.9 2003/08/07 09:37:01 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" const struct objs dayobjs[] = { {236, HORSE}, {237, CAR}, {275, POT}, {275, BAR}, {275, BLOCK}, {260, COINS}, {266, DARK}, {235, TIMER}, {51, 51}, {59, 51}, {48, 51}, {66, 52}, {65, 52}, {19, BOMB}, {167, NATIVE}, {21, KNIFE}, {30, KNIFE}, {30, CLEAVER}, {260, SWORD}, {70, LAND}, {71, LAND}, {72, LAND}, {73, LAND}, {74, LAND}, {75, LAND}, {76, LAND}, {77, LAND}, {78, LAND}, {79, LAND}, {81, LAND}, {82, LAND}, {83, LAND}, {84, LAND}, {85, LAND}, {86, LAND}, {87, LAND}, {88, LAND}, {90, LAND}, {95, LAND}, {96, LAND}, {97, LAND}, {99, LAND}, {100, LAND}, {104, LAND}, {172, WOODSMAN}, {172, DEADWOOD}, {172, MALLET}, {146, ELF}, {146, HALBERD}, {146, SHIELD}, {190, TWO_HANDED}, {190, POTION}, {142, BROAD}, {258, MAIL}, {258, HELM}, {21, MAID}, {7, VIPER}, {216, SHOES}, {64, CYLON}, {36, CYLON}, {49, CYLON}, {8, ROBE}, {13, AMULET}, {20, LASER}, {126, BATHGOD}, {26, GRENADE}, {256, GRENADE}, {237, CHAIN}, {237, COMPASS}, {218, LEVIS}, {164, MACE}, {137, SHOVEL}, {11, COINS}, {24, MATCHES}, {235, MATCHES}, {93, MAN}, {109, PAPAYAS}, {110, PINEAPPLE}, {152, PINEAPPLE}, {154, PINEAPPLE}, {111, KIWI}, {149, MANGO}, {112, COCONUTS}, {150, COCONUTS}, {151, COCONUTS}, {153, COCONUTS}, {192, COCONUTS}, {204, COCONUTS}, {207, COCONUTS}, {209, COCONUTS}, {213, COCONUTS}, {240, COCONUTS}, {218, RING}, {130, BRACELET}, {93, GIRL}, {268, LAMPON}, {0, 0} }; bsd-games-2.17/battlestar/misc.c0000664000175000017500000000427407767741711015273 0ustar jsm28jsm28/* $NetBSD: misc.c,v 1.8 2003/08/07 09:37:02 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: misc.c,v 1.8 2003/08/07 09:37:02 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" int card(array, size) /* for beenthere, injuries */ const char *array; int size; { const char *end = array + size; int i = 0; while (array < end) if (*array++) i++; return (i); } int ucard(array) const unsigned int *array; { int j = 0, n; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(array, n)) j++; return (j); } bsd-games-2.17/battlestar/Makefrag0000664000175000017500000000353306773402557015627 0ustar jsm28jsm28# Makefrag - makefile fragment for battlestar # # Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. battlestar_DEFS := $(FGETLN_DEFS) battlestar_DIRS := $(GAMESDIR) $(MAN6DIR) battlestar_all: battlestar/battlestar battlestar/battlestar.6 battlestar_install: battlestar_all $(INSTALL_SCORE_GAME) battlestar/battlestar $(INSTALL_PREFIX)$(GAMESDIR)/battlestar $(HIDE_GAME) battlestar $(INSTALL_MANUAL) battlestar/battlestar.6 $(INSTALL_SCORE_FILE) $(BATTLESTAR_SCOREFILE) bsd-games-2.17/hack/0000775000175000017500000000000010205246611012702 5ustar jsm28jsm28bsd-games-2.17/hack/def.objclass.h0000664000175000017500000001167007767741711015441 0ustar jsm28jsm28/* $NetBSD: def.objclass.h,v 1.6 2003/04/02 18:36:34 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_OBJCLASS_H_ #define _DEF_OBJCLASS_H_ /* definition of a class of objects */ struct objclass { const char *oc_name; /* actual name */ const char *oc_descr; /* description when name unknown */ char *oc_uname; /* called by user */ Bitfield(oc_name_known,1); Bitfield(oc_merge,1); /* merge otherwise equal objects */ char oc_olet; schar oc_prob; /* probability for mkobj() */ schar oc_delay; /* delay when using such an object */ uchar oc_weight; schar oc_oc1, oc_oc2; int oc_oi; #define nutrition oc_oi /* for foods */ #define a_ac oc_oc1 /* for armors - only used in ARM_BONUS */ #define ARM_BONUS(obj) ((10 - objects[obj->otyp].a_ac) + obj->spe) #define a_can oc_oc2 /* for armors */ #define bits oc_oc1 /* for wands and rings */ /* wands */ #define NODIR 1 #define IMMEDIATE 2 #define RAY 4 /* rings */ #define SPEC 1 /* +n is meaningful */ #define wldam oc_oc1 /* for weapons and PICK_AXE */ #define wsdam oc_oc2 /* for weapons and PICK_AXE */ #define g_val oc_oi /* for gems: value on exit */ }; extern struct objclass objects[]; /* definitions of all object-symbols */ #define ILLOBJ_SYM '\\' #define AMULET_SYM '"' #define FOOD_SYM '%' #define WEAPON_SYM ')' #define TOOL_SYM '(' #define BALL_SYM '0' #define CHAIN_SYM '_' #define ROCK_SYM '`' #define ARMOR_SYM '[' #define POTION_SYM '!' #define SCROLL_SYM '?' #define WAND_SYM '/' #define RING_SYM '=' #define GEM_SYM '*' /* Other places with explicit knowledge of object symbols: * ....shk.c: char shtypes[] = "=/)%?!["; * mklev.c: "=/)%?![<>" * hack.mkobj.c: char mkobjstr[] = "))[[!!!!????%%%%/=**"; * hack.apply.c: otmp = getobj("0#%", "put in"); * hack.eat.c: otmp = getobj("%", "eat"); * hack.invent.c: if(index("!%?[)=*(0/\"", sym)){ * hack.invent.c: || index("%?!*",otmp->olet))){ */ #endif /* _DEF_OBJCLASS_H_ */ bsd-games-2.17/hack/def.monst.h0000664000175000017500000001216507767741711015001 0ustar jsm28jsm28/* $NetBSD: def.monst.h,v 1.7 2003/04/02 18:36:34 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_MONST_H_ #define _DEF_MONST_H_ struct monst { struct monst *nmon; const struct permonst *data; unsigned m_id; xchar mx,my; xchar mdx,mdy; /* if mdispl then pos where last displayed */ #define MTSZ 4 coord mtrack[MTSZ]; /* monster track */ schar mhp,mhpmax; char mappearance; /* nonzero for undetected 'M's and for '1's */ Bitfield(mimic,1); /* undetected mimic */ Bitfield(mdispl,1); /* mdx,mdy valid */ Bitfield(minvis,1); /* invisible */ Bitfield(cham,1); /* shape-changer */ Bitfield(mhide,1); /* hides beneath objects */ Bitfield(mundetected,1); /* not seen in present hiding place */ Bitfield(mspeed,2); Bitfield(msleep,1); Bitfield(mfroz,1); Bitfield(mconf,1); Bitfield(mflee,1); /* fleeing */ Bitfield(mfleetim,7); /* timeout for mflee */ Bitfield(mcan,1); /* has been cancelled */ Bitfield(mtame,1); /* implies peaceful */ Bitfield(mpeaceful,1); /* does not attack unprovoked */ Bitfield(isshk,1); /* is shopkeeper */ Bitfield(isgd,1); /* is guard */ Bitfield(mcansee,1); /* cansee 1, temp.blinded 0, blind 0 */ Bitfield(mblinded,7); /* cansee 0, temp.blinded n, blind 0 */ Bitfield(mtrapped,1); /* trapped in a pit or bear trap */ Bitfield(mnamelth,6); /* length of name (following mxlth) */ #ifndef NOWORM Bitfield(wormno,5); /* at most 31 worms on any level */ #endif /* NOWORM */ unsigned mtrapseen; /* bitmap of traps we've been trapped in */ long mlstmv; /* prevent two moves at once */ struct obj *minvent; long mgold; unsigned mxlth; /* length of following data */ /* in order to prevent alignment problems mextra should be (or follow) a long int */ long mextra[1]; /* monster dependent info */ }; #define newmonst(xl) (struct monst *) alloc((unsigned)(xl) + sizeof(struct monst)) extern struct monst *fmon; extern struct monst *fallen_down; /* these are in mspeed */ #define MSLOW 1 /* slow monster */ #define MFAST 2 /* speeded monster */ #define NAME(mtmp) (((char *) mtmp->mextra) + mtmp->mxlth) #define MREGEN "TVi1" #define UNDEAD "ZVW " #endif /* _DEF_MONST_H_ */ bsd-games-2.17/hack/hack.pri.c0000664000175000017500000004066110005073236014553 0ustar jsm28jsm28/* $NetBSD: hack.pri.c,v 1.8 2003/04/02 18:36:39 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.pri.c,v 1.8 2003/04/02 18:36:39 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on * screen */ void swallowed() { char ulook[] = "|@|"; ulook[1] = u.usym; cls(); curs(u.ux - 1, u.uy + 1); fputs("/-\\", stdout); curx = u.ux + 2; curs(u.ux - 1, u.uy + 2); fputs(ulook, stdout); curx = u.ux + 2; curs(u.ux - 1, u.uy + 3); fputs("\\-/", stdout); curx = u.ux + 2; u.udispl = 1; u.udisx = u.ux; u.udisy = u.uy; } /* VARARGS1 */ boolean panicking; void panic(const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (panicking++) exit(1); /* avoid loops - this should never happen */ home(); puts(" Suddenly, the dungeon collapses."); fputs(" ERROR: ", stdout); vprintf(fmt, ap); va_end(ap); #ifdef DEBUG #ifdef UNIX if (!fork()) abort(); /* generate core dump */ #endif /* UNIX */ #endif /* DEBUG */ more(); /* contains a fflush() */ done("panicked"); } void atl(x, y, ch) int x, y, ch; { struct rm *crm = &levl[x][y]; if (x < 0 || x > COLNO - 1 || y < 0 || y > ROWNO - 1) { impossible("atl(%d,%d,%c)", x, y, ch); return; } if (crm->seen && crm->scrsym == ch) return; crm->scrsym = ch; crm->new = 1; on_scr(x, y); } void on_scr(x, y) int x, y; { if (x < scrlx) scrlx = x; if (x > scrhx) scrhx = x; if (y < scrly) scrly = y; if (y > scrhy) scrhy = y; } /* * call: (x,y) - display (-1,0) - close (leave last symbol) (-1,-1)- close * (undo last symbol) (-1,let)-open: initialize symbol (-2,let)-change let */ void tmp_at(x, y) schar x, y; { static schar prevx, prevy; static char let; if ((int) x == -2) { /* change let call */ let = y; return; } if ((int) x == -1 && (int) y >= 0) { /* open or close call */ let = y; prevx = -1; return; } if (prevx >= 0 && cansee(prevx, prevy)) { delay_output(); prl(prevx, prevy); /* in case there was a monster */ at(prevx, prevy, levl[prevx][prevy].scrsym); } if (x >= 0) { /* normal call */ if (cansee(x, y)) at(x, y, let); prevx = x; prevy = y; } else { /* close call */ let = 0; prevx = -1; } } /* like the previous, but the symbols are first erased on completion */ void Tmp_at(x, y) schar x, y; { static char let; static xchar cnt; static coord tc[COLNO]; /* but watch reflecting beams! */ int xx, yy; if ((int) x == -1) { if (y > 0) { /* open call */ let = y; cnt = 0; return; } /* close call (do not distinguish y==0 and y==-1) */ while (cnt--) { xx = tc[cnt].x; yy = tc[cnt].y; prl(xx, yy); at(xx, yy, levl[xx][yy].scrsym); } cnt = let = 0; /* superfluous */ return; } if ((int) x == -2) { /* change let call */ let = y; return; } /* normal call */ if (cansee(x, y)) { if (cnt) delay_output(); at(x, y, let); tc[cnt].x = x; tc[cnt].y = y; if (++cnt >= COLNO) panic("Tmp_at overflow?"); levl[x][y].new = 0; /* prevent pline-nscr erasing --- */ } } void setclipped() { error("Hack needs a screen of size at least %d by %d.\n", ROWNO + 2, COLNO); } void at(x, y, ch) xchar x, y; char ch; { #ifndef lint /* if xchar is unsigned, lint will complain about if(x < 0) */ if (x < 0 || x > COLNO - 1 || y < 0 || y > ROWNO - 1) { impossible("At gets 0%o at %d %d.", ch, x, y); return; } #endif /* lint */ if (!ch) { impossible("At gets null at %d %d.", x, y); return; } y += 2; curs(x, y); (void) putchar(ch); curx++; } void prme() { if (!Invisible) at(u.ux, u.uy, u.usym); } int doredraw() { docrt(); return (0); } void docrt() { int x, y; struct rm *room; struct monst *mtmp; if (u.uswallow) { swallowed(); return; } cls(); /* * Some ridiculous code to get display of @ and monsters (almost) * right */ if (!Invisible) { levl[(u.udisx = u.ux)][(u.udisy = u.uy)].scrsym = u.usym; levl[u.udisx][u.udisy].seen = 1; u.udispl = 1; } else u.udispl = 0; seemons(); /* reset old positions */ for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) mtmp->mdispl = 0; seemons(); /* force new positions to be shown */ /* * This nonsense should disappear soon * --------------------------------- */ for (y = 0; y < ROWNO; y++) for (x = 0; x < COLNO; x++) if ((room = &levl[x][y])->new) { room->new = 0; at(x, y, room->scrsym); } else if (room->seen) at(x, y, room->scrsym); scrlx = COLNO; scrly = ROWNO; scrhx = scrhy = 0; flags.botlx = 1; bot(); } void docorner(xmin, ymax) int xmin, ymax; { int x, y; struct rm *room; struct monst *mtmp; if (u.uswallow) { /* Can be done more efficiently */ swallowed(); return; } seemons(); /* reset old positions */ for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp->mx >= xmin && mtmp->my < ymax) mtmp->mdispl = 0; seemons(); /* force new positions to be shown */ for (y = 0; y < ymax; y++) { if (y > ROWNO && CD) break; curs(xmin, y + 2); cl_end(); if (y < ROWNO) { for (x = xmin; x < COLNO; x++) { if ((room = &levl[x][y])->new) { room->new = 0; at(x, y, room->scrsym); } else if (room->seen) at(x, y, room->scrsym); } } } if (ymax > ROWNO) { cornbot(xmin - 1); if (ymax > ROWNO + 1 && CD) { curs(1, ROWNO + 3); cl_eos(); } } } void curs_on_u() { curs(u.ux, u.uy + 2); } void pru() { if (u.udispl && (Invisible || u.udisx != u.ux || u.udisy != u.uy)) /* if(! levl[u.udisx][u.udisy].new) */ if (!vism_at(u.udisx, u.udisy)) newsym(u.udisx, u.udisy); if (Invisible) { u.udispl = 0; prl(u.ux, u.uy); } else if (!u.udispl || u.udisx != u.ux || u.udisy != u.uy) { atl(u.ux, u.uy, u.usym); u.udispl = 1; u.udisx = u.ux; u.udisy = u.uy; } levl[u.ux][u.uy].seen = 1; } #ifndef NOWORM #include "def.wseg.h" #endif /* NOWORM */ /* print a position that is visible for @ */ void prl(int x, int y) { struct rm *room; struct monst *mtmp; struct obj *otmp; if (x == u.ux && y == u.uy && (!Invisible)) { pru(); return; } if (!isok(x, y)) return; room = &levl[x][y]; if ((!room->typ) || (IS_ROCK(room->typ) && levl[u.ux][u.uy].typ == CORR)) return; if ((mtmp = m_at(x, y)) && !mtmp->mhide && (!mtmp->minvis || See_invisible)) { #ifndef NOWORM if (m_atseg) pwseg(m_atseg); else #endif /* NOWORM */ pmon(mtmp); } else if ((otmp = o_at(x, y)) && room->typ != POOL) atl(x, y, otmp->olet); else if (mtmp && (!mtmp->minvis || See_invisible)) { /* must be a hiding monster, but not hiding right now */ /* assume for the moment that long worms do not hide */ pmon(mtmp); } else if (g_at(x, y) && room->typ != POOL) atl(x, y, '$'); else if (!room->seen || room->scrsym == ' ') { room->new = room->seen = 1; newsym(x, y); on_scr(x, y); } room->seen = 1; } char news0(x, y) xchar x, y; { struct obj *otmp; struct trap *ttmp; struct rm *room; char tmp; room = &levl[x][y]; if (!room->seen) tmp = ' '; else if (room->typ == POOL) tmp = POOL_SYM; else if (!Blind && (otmp = o_at(x, y))) tmp = otmp->olet; else if (!Blind && g_at(x, y)) tmp = '$'; else if (x == xupstair && y == yupstair) tmp = '<'; else if (x == xdnstair && y == ydnstair) tmp = '>'; else if ((ttmp = t_at(x, y)) && ttmp->tseen) tmp = '^'; else switch (room->typ) { case SCORR: case SDOOR: tmp = room->scrsym; /* %% wrong after killing * mimic ! */ break; case HWALL: tmp = '-'; break; case VWALL: tmp = '|'; break; case LDOOR: case DOOR: tmp = '+'; break; case CORR: tmp = CORR_SYM; break; case ROOM: if (room->lit || cansee(x, y) || Blind) tmp = '.'; else tmp = ' '; break; /* case POOL: tmp = POOL_SYM; break; */ default: tmp = ERRCHAR; } return (tmp); } void newsym(x, y) int x, y; { atl(x, y, news0(x, y)); } /* used with wand of digging (or pick-axe): fill scrsym and force display */ /* also when a POOL evaporates */ void mnewsym(x, y) int x, y; { struct rm *room; char newscrsym; if (!vism_at(x, y)) { room = &levl[x][y]; newscrsym = news0(x, y); if (room->scrsym != newscrsym) { room->scrsym = newscrsym; room->seen = 0; } } } void nosee(x, y) int x, y; { struct rm *room; if (!isok(x, y)) return; room = &levl[x][y]; if (room->scrsym == '.' && !room->lit && !Blind) { room->scrsym = ' '; room->new = 1; on_scr(x, y); } } #ifndef QUEST void prl1(x, y) int x, y; { if (u.dx) { if (u.dy) { prl(x - (2 * u.dx), y); prl(x - u.dx, y); prl(x, y); prl(x, y - u.dy); prl(x, y - (2 * u.dy)); } else { prl(x, y - 1); prl(x, y); prl(x, y + 1); } } else { prl(x - 1, y); prl(x, y); prl(x + 1, y); } } void nose1(x, y) int x, y; { if (u.dx) { if (u.dy) { nosee(x, u.uy); nosee(x, u.uy - u.dy); nosee(x, y); nosee(u.ux - u.dx, y); nosee(u.ux, y); } else { nosee(x, y - 1); nosee(x, y); nosee(x, y + 1); } } else { nosee(x - 1, y); nosee(x, y); nosee(x + 1, y); } } #endif /* QUEST */ int vism_at(x, y) int x, y; { struct monst *mtmp; return ((x == u.ux && y == u.uy && !Invisible) ? 1 : (mtmp = m_at(x, y)) ? ((Blind && Telepat) || canseemon(mtmp)) : 0); } #ifdef NEWSCR void pobj(obj) struct obj *obj; { int show = (!obj->oinvis || See_invisible) && cansee(obj->ox, obj->oy); if (obj->odispl) { if (obj->odx != obj->ox || obj->ody != obj->oy || !show) if (!vism_at(obj->odx, obj->ody)) { newsym(obj->odx, obj->ody); obj->odispl = 0; } } if (show && !vism_at(obj->ox, obj->oy)) { atl(obj->ox, obj->oy, obj->olet); obj->odispl = 1; obj->odx = obj->ox; obj->ody = obj->oy; } } #endif /* NEWSCR */ void unpobj(obj) struct obj *obj; { /* * if(obj->odispl){ if(!vism_at(obj->odx, obj->ody)) newsym(obj->odx, * obj->ody); obj->odispl = 0; } */ if (!vism_at(obj->ox, obj->oy)) newsym(obj->ox, obj->oy); } void seeobjs() { struct obj *obj, *obj2; for (obj = fobj; obj; obj = obj2) { obj2 = obj->nobj; if (obj->olet == FOOD_SYM && obj->otyp >= CORPSE && obj->age + 250 < moves) delobj(obj); } for (obj = invent; obj; obj = obj2) { obj2 = obj->nobj; if (obj->olet == FOOD_SYM && obj->otyp >= CORPSE && obj->age + 250 < moves) useup(obj); } } void seemons() { struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (mtmp->data->mlet == ';') mtmp->minvis = (u.ustuck != mtmp && levl[mtmp->mx][mtmp->my].typ == POOL); pmon(mtmp); #ifndef NOWORM if (mtmp->wormno) wormsee(mtmp->wormno); #endif /* NOWORM */ } } void pmon(mon) struct monst *mon; { int show = (Blind && Telepat) || canseemon(mon); if (mon->mdispl) { if (mon->mdx != mon->mx || mon->mdy != mon->my || !show) unpmon(mon); } if (show && !mon->mdispl) { atl(mon->mx, mon->my, (!mon->mappearance || u.uprops[PROP(RIN_PROTECTION_FROM_SHAPE_CHANGERS)].p_flgs ) ? mon->data->mlet : mon->mappearance); mon->mdispl = 1; mon->mdx = mon->mx; mon->mdy = mon->my; } } void unpmon(mon) struct monst *mon; { if (mon->mdispl) { newsym(mon->mdx, mon->mdy); mon->mdispl = 0; } } void nscr() { int x, y; struct rm *room; if (u.uswallow || u.ux == FAR || flags.nscrinh) return; pru(); for (y = scrly; y <= scrhy; y++) for (x = scrlx; x <= scrhx; x++) if ((room = &levl[x][y])->new) { room->new = 0; at(x, y, room->scrsym); } scrhx = scrhy = 0; scrlx = COLNO; scrly = ROWNO; } /* 100 suffices for bot(); no relation with COLNO */ char oldbot[100], newbot[100]; void cornbot(lth) int lth; { if (lth < (int)sizeof(oldbot)) { oldbot[lth] = 0; flags.botl = 1; } } void bot() { char *ob = oldbot, *nb = newbot; int i; if (flags.botlx) *ob = 0; flags.botl = flags.botlx = 0; #ifdef GOLD_ON_BOTL (void) sprintf(newbot, "Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ", dlevel, u.ugold, u.uhp, u.uhpmax, u.uac); #else (void) sprintf(newbot, "Level %-2d Hp %3d(%d) Ac %-2d Str ", dlevel, u.uhp, u.uhpmax, u.uac); #endif /* GOLD_ON_BOTL */ if (u.ustr > 18) { if (u.ustr > 117) (void) strcat(newbot, "18/**"); else (void) sprintf(eos(newbot), "18/%02d", u.ustr - 18); } else (void) sprintf(eos(newbot), "%-2d ", u.ustr); #ifdef EXP_ON_BOTL (void) sprintf(eos(newbot), " Exp %2d/%-5lu ", u.ulevel, u.uexp); #else (void) sprintf(eos(newbot), " Exp %2u ", u.ulevel); #endif /* EXP_ON_BOTL */ (void) strcat(newbot, hu_stat[u.uhs]); if (flags.time) (void) sprintf(eos(newbot), " %ld", moves); if (strlen(newbot) >= COLNO) { char *bp0, *bp1; bp0 = bp1 = newbot; do { if (*bp0 != ' ' || bp0[1] != ' ' || bp0[2] != ' ') *bp1++ = *bp0; } while (*bp0++); } for (i = 1; i < COLNO; i++) { if (*ob != *nb) { curs(i, ROWNO + 2); (void) putchar(*nb ? *nb : ' '); curx++; } if (*ob) ob++; if (*nb) nb++; } (void) strcpy(oldbot, newbot); } #ifdef WAN_PROBING void mstatusline(mtmp) struct monst *mtmp; { pline("Status of %s: ", monnam(mtmp)); pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d", mtmp->data->mlevel, mtmp->mgold, mtmp->mhp, mtmp->mhpmax, mtmp->data->ac, (mtmp->data->damn + 1) * (mtmp->data->damd + 1)); } #endif /* WAN_PROBING */ void cls() { if (flags.toplin == 1) more(); flags.toplin = 0; clear_screen(); flags.botlx = 1; } bsd-games-2.17/hack/alloc.c0000664000175000017500000000774507767741711014201 0ustar jsm28jsm28/* $NetBSD: alloc.c,v 1.5 2003/04/02 18:36:33 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: alloc.c,v 1.5 2003/04/02 18:36:33 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" #ifdef LINT /* a ridiculous definition, suppressing "possible pointer alignment problem" for (long *) malloc() "enlarg defined but never used" "ftell defined (in ) but never used" from lint */ long * alloc(n) unsigned n; { long dummy = ftell(stderr); if (n) dummy = 0; /* make sure arg is used */ return (&dummy); } #else long * alloc(lth) unsigned lth; { char *ptr; if (!(ptr = malloc(lth))) panic("Cannot get %d bytes", lth); return ((long *) ptr); } long * enlarge(ptr, lth) char *ptr; unsigned lth; { char *nptr; if (!(nptr = realloc(ptr, lth))) panic("Cannot reallocate %d bytes", lth); return ((long *) nptr); } #endif /* LINT */ bsd-games-2.17/hack/data0000664000175000017500000002311110032065423013532 0ustar jsm28jsm28 Hack & Quest data file - version 1.0.3 @ human (or you) - a wall | a wall + a door . the floor of a room a dark part of a room # a corridor } water filled area < the staircase to the previous level > the staircase to the next level ^ a trap $ a pile, pot or chest of gold %% a piece of food ! a potion * a gem ? a scroll = a ring / a wand [ a suit of armor ) a weapon ( a useful item (camera, key, rope etc.) 0 an iron ball _ an iron chain ` an enormous rock " an amulet , a trapper : a chameleon ; a giant eel ' a lurker above & a demon A a giant ant B a giant bat C a centaur; Of all the monsters put together by the Greek imagination the Centaurs (Kentauroi) constituted a class in themselves. Despite a strong streak of sensuality in their make-up, their normal behaviour was moral, and they took a kindly thought of man's welfare. The attempted outrage of Nessos on Deianeira, and that of the whole tribe of Centaurs on the Lapith women, are more than offset by the hospitality of Pholos and by the wisdom of Cheiron, physician, prophet, lyrist, and the instructor of Achilles. Further, the Cen- taurs were peculiar in that their nature, which united the body of a horse with the trunk and head of a man, involved an unthinkable duplication of vital organs and important members. So grotesque a combination seems almost un-Greek. These strange creatures were said to live in the caves and clefts of the mountains, myths associating them especially with the hills of Thessaly and the range of Erymanthos. [Mythology of all races, Vol. 1, pp. 270-271] D a dragon; In the West the dragon was the natural enemy of man. Although preferring to live in bleak and desolate regions, whenever it was seen among men it left in its wake a trail of destruction and disease. Yet any attempt to slay this beast was a perilous under- taking. For the dragon's assailant had to contend not only with clouds of sulphurous fumes pouring from its fire-breathing nos- trils, but also with the thrashings of its tail, the most deadly part of its serpent-like body. [From: Mythical Beasts by Deirdre Headon (The Leprechaun Library)] E a floating eye F a freezing sphere G a gnome; ... And then a gnome came by, carrying a bundle, an old fellow three times as large as an imp and wearing clothes of a sort, especially a hat. And he was clearly just as frightened as the imps though he could not go so fast. Ramon Alonzo saw that there must be some great trouble that was vexing magical things; and, since gnomes speak the language of men, and will answer if spoken to gently, he raised his hat, and asked of the gnome his name. The gnome did not stop his hasty shuffle a moment as he answered 'Alaraba' and grabbed the rim of his hat but forgot to doff it. 'What is the trouble, Alaraba?' said Ramon Alonzo. 'White magic. Run!' said the gnome ... [From: The Charwoman's Shadow, by Lord Dunsany.] H a hobgoblin; Hobgoblin. Used by the Puritans and in later times for wicked goblin spirits, as in Bunyan's 'Hobgoblin nor foul friend', but its more correct use is for the friendly spir- its of the brownie type. In 'A midsummer night's dream' a fairy says to Shakespeare's Puck: Those that Hobgoblin call you, and sweet Puck, You do their work, and they shall have good luck: Are you not he? and obviously Puck would not wish to be called a hobgoblin if that was an ill-omened word. Hobgoblins are on the whole, good-humoured and ready to be helpful, but fond of practical joking, and like most of the fairies rather nasty people to annoy. Boggarts hover on the verge of hobgoblindom. Bogles are just over the edge. One Hob mentioned by Henderson, was Hob Headless who haunted the road between Hurworth and Neasham, but could not cross the little river Kent, which flowed into the Tess. He was exorcised and laid under a large stone by the roadside for ninety-nine years and a day. If anyone was so unwary as to sit on that stone, he would be unable to quit it for ever. The ninety-nine years is nearly up, so trouble may soon be heard of on the road between Hurworth and Neasham. [Katharine Briggs, A dictionary of Fairies] I an invisible stalker J a jackal K a kobold L a leprechaun; The Irish Leprechaun is the Faeries' shoemaker and is known under various names in different parts of Ireland: Cluri- caune in Cork, Lurican in Kerry, Lurikeen in Kildare and Lu- rigadaun in Tipperary. Although he works for the Faeries, the Leprechaun is not of the same species. He is small, has dark skin and wears strange clothes. His nature has some- thing of the manic-depressive about it: first he is quite happy, whistling merrily as he nails a sole on to a shoe; a few minutes later, he is sullen and morose, drunk on his home-made heather ale. The Leprechaun's two great loves are tobacco and whiskey, and he is a first-rate con-man, impos- sible to out-fox. No one, no matter how clever, has ever managed to cheat him out of his hidden pot of gold or his magic shilling. At the last minute he always thinks of some way to divert his captor's attention and vanishes in the twinkling of an eye. [From: A Field Guide to the Little People by Nancy Arrowsmith & George Moorse. ] M a mimic N a nymph O an orc P a purple worm Q a quasit R a rust monster S a snake T a troll U an umber hulk V a vampire W a wraith X a xorn Y a yeti Z a zombie a an acid blob b a giant beetle c a cockatrice; Once in a great while, when the positions of the stars are just right, a seven-year-old rooster will lay an egg. Then, along will come a snake, to coil around the egg, or a toad, to squat upon the egg, keeping it warm and helping it to hatch. When it hatches, out comes a creature called basil- isk, or cockatrice, the most deadly of all creatures. A sin- gle glance from its yellow, piercing toad's eyes will kill both man and beast. Its power of destruction is said to be so great that sometimes simply to hear its hiss can prove fatal. Its breath is so venomous that it causes all vege- tation to wither. There is, however, one creature which can withstand the basilisk's deadly gaze, and this is the weasel. No one knows why this is so, but although the fierce weasel can slay the basilisk, it will itself be killed in the struggle. Perhaps the weasel knows the basilisk's fatal weakness: if it ever sees its own reflection in a mirror it will perish instant- ly. But even a dead basilisk is dangerous, for it is said that merely touching its lifeless body can cause a person to sicken and die. [From: Mythical Beasts by Deirdre Headon (The Leprechaun Library) and other sources. ] d a dog e an ettin f a fog cloud g a gelatinous cube h a homunculus i an imp; ... imps ... little creatures of two feet high that could gambol and jump prodigiously; ... [From: The Charwoman's Shadow, by Lord Dunsany.] An 'imp' is an off-shoot or cutting. Thus an 'ymp tree' was a grafted tree, or one grown from a cutting, not from seed. 'Imp' properly means a small devil, an off-shoot of Satan, but the distinction between goblins or bogles and imps from hell is hard to make, and many in the Celtic countries as well as the English Puritans regarded all fairies as devils. The fairies of tradition often hover uneasily between the ghostly and the diabolic state. [Katharine Briggs, A dictionary of Fairies] j a jaguar k a killer bee l a leocrotta m a minotaur n a nurse o an owlbear p a piercer q a quivering blob r a giant rat s a scorpion t a tengu; The tengu was the most troublesome creature of Japanese legend. Part bird and part man, with red beak for a nose and flashing eyes, the tengu was notorious for stirring up feuds and prolonging enmity between families. Indeed, the belligerent tengus were supposed to have been man's first instructors in the use of arms. [From: Mythical Beasts by Deirdre Headon (The Leprechaun Library). ] u a unicorn; Men have always sought the elusive unicorn, for the single twisted horn which projected from its forehead was thought to be a powerful talisman. It was said that the unicorn had simply to dip the tip of its horn in a muddy pool for the water to become pure. Men also believed that to drink from this horn was a protection against all sickness, and that if the horn was ground to a powder it would act as an antidote to all poisons. Less than 200 years ago in France, the horn of a unicorn was used in a ceremony to test the royal food for poison. Although only the size of a small horse, the unicorn is a very fierce beast, capable of killing an elephant with a single thrust from its horn. Its fleetness of foot also makes this solitary creature difficult to capture. However, it can be tamed and captured by a maiden. Made gentle by the sight of a virgin, the unicorn can be lured to lay its head in her lap, and in this docile mood, the maiden may secure it with a golden rope. [From: Mythical Beasts by Deirdre Headon (The Leprechaun Library). ] v a violet fungi w a long worm; From its teeth the crysknife can be manufactured. ~ the tail of a long worm x a xan; The xan were animals sent to prick the legs of the Lords of Xibalba. y a yellow light z a zruty; The zruty are wild and gigantic beings, living in the wildernesses of the Tatra mountains. 1 The wizard of Yendor 2 The mail daemon bsd-games-2.17/hack/Original_READ_ME0000664000175000017500000000514007077410364015560 0ustar jsm28jsm28$NetBSD: Original_READ_ME,v 1.2 1995/03/23 08:29:10 cgd Exp $ This is export hack, my first semester programming project. To set it up for your system, you will have to do the following: 1: create a hack uid, to own the top ten list, etc. 2: create a hack directory "/usr/lib/game/hack" is the default. 2.5: make the directory 700 mode. /* sav files go in there...*/ 3: modify hack.main.c to use the new directory. 4: modify hack.main.c so it uses the new hack gid. Gid accounts can go into magic mode without the password, can get cores with ^G, etc. (make sure gid isn't checked anywhere else...) 5: recompile hack. 6: put it in games after making it set-uid hack. 8: fix the bugs I undobtedly left in it. 9: tell me what you think of it. Hack uses the UCB file /etc/termcap to get your terminal escape codes. If you don't use it, you will have to make extensive changes to hack.pri.c If you find any bugs (That you think I don't know about), or have any awesome new changes (Like a better save (One that works!)), or have ANY questions, write me Jay Fenlason 29 East St. Sudbury Mass. 01776 or call me at (617) 443-5036. Since I have both a modem and a teen-age sister, Good Luck. Hack is split (roughly) into several source files that do different things. I have tried to fit all the procedures having to do with a certain segment of the game into a single file, but the job is not the best in the world. The rough splits are: hack.c General random stuff and things I never got around to moving. hack.main.c main() and other random procedures, also the lock file stuff. hack.mon.c Monsters, moving, attacking, etc. hack.do.c drink, eat, read, wield, save, etc. hack.do1.c zap, wear, remove, etc... hack.pri.c stuff having to do with the screen, most of the terminal independant stuff is in here. hack.lev.c temp files and calling of mklev. Because of the peculiar restraints on our system, I make mklev (create a level) a separate procedure execd by hack when needed. The source for mklev is (Naturaly) mklev.c. You may want to put mklev back into hack. Good luck. Most of hack was written by me, with help from Kenny Woodland (KW) (general random things including the original BUZZ()) Mike Thome (MT) (The original chamelian) and Jon Payne (JP) (The original lock file kludge and the massive CURS()) This entire program would not have been possible without the SFSU Logo Workshop. I am eternally grateful to all of our students (Especially K.L.), without whom I would never have seen Rogue. I am especially grateful to Mike Clancy, without whose generous help I would never have gotten to play ROGUE. bsd-games-2.17/hack/hack.termcap.c0000664000175000017500000002025010204250367015407 0ustar jsm28jsm28/* $NetBSD: hack.termcap.c,v 1.12 2003/04/02 18:36:40 jsm Exp $ */ /* For Linux: still using old termcap interface from version 1.9. */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.termcap.c,v 1.12 2003/04/02 18:36:40 jsm Exp $"); #endif /* not lint */ #include #include #include #include #include #include "hack.h" #include "extern.h" #include "def.flag.h" /* for flags.nonull */ static char tbuf[512]; char *HO, *CL, *CE, *UP, *CM, *ND, *XD, *BC, *SO, *SE, *TI, *TE; static char *VS, *VE; static int SG; char PC = '\0'; char *CD; /* tested in pri.c: docorner() */ int CO, LI; /* used in pri.c and whatis.c */ void startup() { char *term; char *tptr; char *tbufptr, *pc; tptr = (char *) alloc(1024); tbufptr = tbuf; if (!(term = getenv("TERM"))) error("Can't get TERM."); if (!strncmp(term, "5620", 4)) flags.nonull = 1; /* this should be a termcap flag */ if (tgetent(tptr, term) < 1) error("Unknown terminal type: %s.", term); if ((pc = tgetstr("pc", &tbufptr)) != NULL) PC = *pc; if (!(BC = tgetstr("bc", &tbufptr))) { if (!tgetflag("bs")) error("Terminal must backspace."); BC = tbufptr; tbufptr += 2; *BC = '\b'; } HO = tgetstr("ho", &tbufptr); CO = tgetnum("co"); LI = tgetnum("li"); if (CO < COLNO || LI < ROWNO + 2) setclipped(); if (!(CL = tgetstr("cl", &tbufptr))) error("Hack needs CL."); ND = tgetstr("nd", &tbufptr); if (tgetflag("os")) error("Hack can't have OS."); CE = tgetstr("ce", &tbufptr); UP = tgetstr("up", &tbufptr); /* * It seems that xd is no longer supported, and we should use a * linefeed instead; unfortunately this requires resetting CRMOD, and * many output routines will have to be modified slightly. Let's * leave that till the next release. */ XD = tgetstr("xd", &tbufptr); /* not: XD = tgetstr("do", &tbufptr); */ if (!(CM = tgetstr("cm", &tbufptr))) { if (!UP && !HO) error("Hack needs CM or UP or HO."); printf("Playing hack on terminals without cm is suspect...\n"); getret(); } SO = tgetstr("so", &tbufptr); SE = tgetstr("se", &tbufptr); SG = tgetnum("sg"); /* -1: not fnd; else # of spaces left by so */ if (!SO || !SE || (SG > 0)) SO = SE = 0; CD = tgetstr("cd", &tbufptr); set_whole_screen(); /* uses LI and CD */ if (tbufptr - tbuf > (int)sizeof(tbuf)) error("TERMCAP entry too big...\n"); free(tptr); } void start_screen() { xputs(TI); xputs(VS); } void end_screen() { xputs(VE); xputs(TE); } /* Cursor movements */ void curs(x, y) int x, y; /* not xchar: perhaps xchar is unsigned and * curx-x would be unsigned as well */ { if (y == cury && x == curx) return; if (!ND && (curx != x || x <= 3)) { /* Extremely primitive */ cmov(x, y); /* bunker!wtm */ return; } if (abs(cury - y) <= 3 && abs(curx - x) <= 3) nocmov(x, y); else if ((x <= 3 && abs(cury - y) <= 3) || (!CM && x < abs(curx - x))) { (void) putchar('\r'); curx = 1; nocmov(x, y); } else if (!CM) { nocmov(x, y); } else cmov(x, y); } void nocmov(x, y) int x, y; { if (cury > y) { if (UP) { while (cury > y) { /* Go up. */ xputs(UP); cury--; } } else if (CM) { cmov(x, y); } else if (HO) { home(); curs(x, y); } /* else impossible("..."); */ } else if (cury < y) { if (XD) { while (cury < y) { xputs(XD); cury++; } } else if (CM) { cmov(x, y); } else { while (cury < y) { xputc('\n'); curx = 1; cury++; } } } if (curx < x) { /* Go to the right. */ if (!ND) cmov(x, y); else /* bah */ /* should instead print what is there already */ while (curx < x) { xputs(ND); curx++; } } else if (curx > x) { while (curx > x) { /* Go to the left. */ xputs(BC); curx--; } } } void cmov(x, y) int x, y; { xputs(tgoto(CM, x - 1, y - 1)); cury = y; curx = x; } int xputc(c) char c; { return (fputc(c, stdout)); } void xputs(s) char *s; { tputs(s, 1, xputc); } void cl_end() { if (CE) xputs(CE); else { /* no-CE fix - free after Harold Rynes */ /* * this looks terrible, especially on a slow terminal but is * better than nothing */ int cx = curx, cy = cury; while (curx < COLNO) { xputc(' '); curx++; } curs(cx, cy); } } void clear_screen() { xputs(CL); curx = cury = 1; } void home() { if (HO) xputs(HO); else if (CM) xputs(tgoto(CM, 0, 0)); else curs(1, 1); /* using UP ... */ curx = cury = 1; } void standoutbeg() { if (SO) xputs(SO); } void standoutend() { if (SE) xputs(SE); } void backsp() { xputs(BC); curx--; } void bell() { (void) putchar('\007'); /* curx does not change */ (void) fflush(stdout); } void delay_output() { /* delay 50 ms - could also use a 'nap'-system call */ /* or the usleep call like this :-) */ usleep(50000); } void cl_eos() { /* free after Robert Viduya *//* must only be * called with curx = 1 */ if (CD) xputs(CD); else { int cx = curx, cy = cury; while (cury <= LI - 2) { cl_end(); xputc('\n'); curx = 1; cury++; } cl_end(); curs(cx, cy); } } bsd-games-2.17/hack/hh0000664000175000017500000000365607077410364013251 0ustar jsm28jsm28y k u Move commands: \|/ hykulnjb: single move in specified direction h-+-l HYKULNJB: repeated move in specified direction /|\ (until stopped by e.g. a wall) b j n f: fast movement in direction (until something interesting is seen) m: move without picking up objects Meta commands: Q quit leave the game S save save the game (to be continued later) ! sh escape to some SHELL ^Z suspend suspend the game (independent of your current suspend char) O set set options ? help print information / whatis give name (and sometimes more info) of specified monster \ known print list of what's been discovered v version print version number ^R redraw redraw the screen (^R denotes the symbol CTRL/R) ^P print repeat last message (subsequent ^P's repeat earlier messages) # introduces a long command; not really implemented Game commands: ^T teleport teleport a apply, use use something (a key, camera, etc.) c call give a name to a class of objects d drop drop an object. d7a: drop seven items of object a. e eat eat something i invent list the inventory (all objects you are carrying) I invent list selected parts of the inventory IU: list unpaid objects IX: list unpaid but used up items I$: count your money p pay pay your bill q drink quaff a potion r read read a scroll s search search for secret doors, hidden traps and monsters t throw throw or shoot a weapon w wield wield a weapon (w- wield nothing) z zap zap a wand C name name an individual monster (e.g., baptize your dog) D Drop drop several things E Engrave write a message in the dust on the floor (E- use fingers) P wear put on a ring R remove remove a ring T remove take off some armor W wear put on some armor < up go up the stairs > down go down the stairs ^ trap_id identify a previously found trap ),[,= ask for current weapon, armor, rings, respectively $ gold count your gold . rest wait a moment , pickup pick up all you can carry : look look at what is here bsd-games-2.17/hack/rnd.c0000664000175000017500000000713307767741711013661 0ustar jsm28jsm28/* $NetBSD: rnd.c,v 1.5 2003/04/02 18:36:42 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: rnd.c,v 1.5 2003/04/02 18:36:42 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" #define RND(x) ((random()>>3) % x) int rn1(x, y) int x, y; { return (RND(x) + y); } int rn2(x) int x; { return (RND(x)); } int rnd(x) int x; { return (RND(x) + 1); } int d(n, x) int n, x; { int tmp = n; while (n--) tmp += RND(x); return (tmp); } bsd-games-2.17/hack/hack.pager.c0000664000175000017500000002655307767741711015110 0ustar jsm28jsm28/* $NetBSD: hack.pager.c,v 1.7 2003/04/02 18:36:39 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.pager.c,v 1.7 2003/04/02 18:36:39 jsm Exp $"); #endif /* not lint */ /* This file contains the command routine dowhatis() and a pager. */ /* * Also readmail() and doshell(), and generally the things that contact the * outside world. */ #include #include #include #include #include "hack.h" #include "extern.h" int dowhatis() { FILE *fp; char bufr[BUFSZ + 6]; char *buf = &bufr[6], *ep, q; if (!(fp = fopen(DATAFILE, "r"))) pline("Cannot open data file!"); else { pline("Specify what? "); q = readchar(); if (q != '\t') while (fgets(buf, BUFSZ, fp)) if (*buf == q) { ep = strchr(buf, '\n'); if (ep) *ep = 0; /* else: bad data file */ /* Expand tab 'by hand' */ if (buf[1] == '\t') { buf = bufr; buf[0] = q; (void) strncpy(buf + 1, " ", 7); } pline(buf); if (ep[-1] == ';') { pline("More info? "); if (readchar() == 'y') { page_more(fp, 1); /* does fclose() */ return (0); } } (void) fclose(fp); /* kopper@psuvax1 */ return (0); } pline("I've never heard of such things."); (void) fclose(fp); } return (0); } /* make the paging of a file interruptible */ static int got_intrup; void intruph(n) int n __attribute__((__unused__)); { got_intrup++; } /* simple pager, also used from dohelp() */ void page_more(fp, strip) FILE *fp; int strip; /* nr of chars to be stripped from each line * (0 or 1) */ { char *bufr, *ep; sig_t prevsig = signal(SIGINT, intruph); set_pager(0); bufr = (char *) alloc((unsigned) CO); bufr[CO - 1] = 0; while (fgets(bufr, CO - 1, fp) && (!strip || *bufr == '\t') && !got_intrup) { ep = strchr(bufr, '\n'); if (ep) *ep = 0; if (page_line(bufr + strip)) { set_pager(2); goto ret; } } set_pager(1); ret: free(bufr); (void) fclose(fp); (void) signal(SIGINT, prevsig); got_intrup = 0; } static boolean whole_screen = TRUE; #define PAGMIN 12 /* minimum # of lines for page below level * map */ void set_whole_screen() { /* called in termcap as soon as LI is known */ whole_screen = (LI - ROWNO - 2 <= PAGMIN || !CD); } #ifdef NEWS int readnews() { int ret; whole_screen = TRUE; /* force a docrt(), our first */ ret = page_file(NEWS, TRUE); set_whole_screen(); return (ret); /* report whether we did docrt() */ } #endif /* NEWS */ void set_pager(mode) int mode; /* 0: open 1: wait+close 2: close */ { static boolean so; if (mode == 0) { if (!whole_screen) { /* clear topline */ clrlin(); /* use part of screen below level map */ curs(1, ROWNO + 4); } else { cls(); } so = flags.standout; flags.standout = 1; } else { if (mode == 1) { curs(1, LI); more(); } flags.standout = so; if (whole_screen) docrt(); else { curs(1, ROWNO + 4); cl_eos(); } } } int page_line(s) /* returns 1 if we should quit */ const char *s; { if (cury == LI - 1) { if (!*s) return (0); /* suppress blank lines at top */ putchar('\n'); cury++; cmore("q\033"); if (morc) { morc = 0; return (1); } if (whole_screen) cls(); else { curs(1, ROWNO + 4); cl_eos(); } } puts(s); cury++; return (0); } /* * Flexible pager: feed it with a number of lines and it will decide * whether these should be fed to the pager above, or displayed in a * corner. * Call: * cornline(0, title or 0) : initialize * cornline(1, text) : add text to the chain of texts * cornline(2, morcs) : output everything and cleanup * cornline(3, 0) : cleanup */ void cornline(mode, text) int mode; const char *text; { static struct line { struct line *next_line; char *line_text; } *texthead, *texttail; static int maxlen; static int linect; struct line *tl; if (mode == 0) { texthead = 0; maxlen = 0; linect = 0; if (text) { cornline(1, text); /* title */ cornline(1, ""); /* blank line */ } return; } if (mode == 1) { int len; if (!text) return; /* superfluous, just to be sure */ linect++; len = strlen(text); if (len > maxlen) maxlen = len; tl = (struct line *) alloc((unsigned) (len + sizeof(struct line) + 1)); tl->next_line = 0; tl->line_text = (char *) (tl + 1); (void) strcpy(tl->line_text, text); if (!texthead) texthead = tl; else texttail->next_line = tl; texttail = tl; return; } /* --- now we really do it --- */ if (mode == 2 && linect == 1) /* topline only */ pline(texthead->line_text); else if (mode == 2) { int curline, lth; if (flags.toplin == 1) more(); /* ab@unido */ remember_topl(); lth = CO - maxlen - 2; /* Use full screen width */ if (linect < LI && lth >= 10) { /* in a corner */ home(); cl_end(); flags.toplin = 0; curline = 1; for (tl = texthead; tl; tl = tl->next_line) { curs(lth, curline); if (curline > 1) cl_end(); putsym(' '); putstr(tl->line_text); curline++; } curs(lth, curline); cl_end(); cmore(text); home(); cl_end(); docorner(lth, curline - 1); } else { /* feed to pager */ set_pager(0); for (tl = texthead; tl; tl = tl->next_line) { if (page_line(tl->line_text)) { set_pager(2); goto cleanup; } } if (text) { cgetret(text); set_pager(2); } else set_pager(1); } } cleanup: while ((tl = texthead) != NULL) { texthead = tl->next_line; free((char *) tl); } } int dohelp() { char c; pline("Long or short help? "); while (((c = readchar()) != 'l') && (c != 's') && !strchr(quitchars, c)) bell(); if (!strchr(quitchars, c)) (void) page_file((c == 'l') ? HELP : SHELP, FALSE); return (0); } int page_file(fnam, silent) /* return: 0 - cannot open fnam; 1 - * otherwise */ const char *fnam; boolean silent; { #ifdef DEF_PAGER /* this implies that UNIX is defined */ { /* use external pager; this may give security problems */ int fd = open(fnam, O_RDONLY); if (fd < 0) { if (!silent) pline("Cannot open %s.", fnam); return (0); } if (child(1)) { /* * Now that child() does a setuid(getuid()) and a * chdir(), we may not be able to open file fnam * anymore, so make it stdin. */ (void) close(0); if (dup(fd)) { if (!silent) printf("Cannot open %s as stdin.\n", fnam); } else { execl(catmore, "page", (char *) 0); if (!silent) printf("Cannot exec %s.\n", catmore); } exit(1); } (void) close(fd); } #else /* DEF_PAGER */ { FILE *f; /* free after Robert Viduya */ if ((f = fopen(fnam, "r")) == (FILE *) 0) { if (!silent) { home(); perror(fnam); flags.toplin = 1; pline("Cannot open %s.", fnam); } return (0); } page_more(f, 0); } #endif /* DEF_PAGER */ return (1); } #ifdef UNIX #ifdef SHELL int dosh() { char *str; if (child(0)) { if ((str = getenv("SHELL")) != NULL) execl(str, str, (char *) 0); else execl("/bin/sh", "sh", (char *) 0); pline("sh: cannot execute."); exit(1); } return (0); } #endif /* SHELL */ #ifdef NOWAITINCLUDE union wait { /* used only for the cast (union wait *) 0 */ int w_status; struct { unsigned short w_Termsig:7; unsigned short w_Coredump:1; unsigned short w_Retcode:8; } w_T; }; #else #ifdef BSD #include #else #include #endif /* BSD */ #endif /* NOWAITINCLUDE */ int child(int wt) { int status; int f; f = fork(); if (f == 0) { /* child */ settty((char *) 0); /* also calls end_screen() */ (void) setuid(getuid()); (void) setgid(getgid()); #ifdef CHDIR (void) chdir(getenv("HOME")); #endif /* CHDIR */ return (1); } if (f == -1) { /* cannot fork */ pline("Fork failed. Try again."); return (0); } /* fork succeeded; wait for child to exit */ (void) signal(SIGINT, SIG_IGN); (void) signal(SIGQUIT, SIG_IGN); (void) wait(&status); gettty(); setftty(); (void) signal(SIGINT, done1); #ifdef WIZARD if (wizard) (void) signal(SIGQUIT, SIG_DFL); #endif /* WIZARD */ if (wt) getret(); docrt(); return (0); } #endif /* UNIX */ bsd-games-2.17/hack/hack.wizard.c0000664000175000017500000002022407767741711015277 0ustar jsm28jsm28/* $NetBSD: hack.wizard.c,v 1.6 2003/04/02 18:36:41 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.wizard.c,v 1.6 2003/04/02 18:36:41 jsm Exp $"); #endif /* not lint */ /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */ #include "hack.h" #include "extern.h" #define WIZSHOT 6 /* one chance in WIZSHOT that wizard will try * magic */ #define BOLT_LIM 8 /* from this distance D and 1 will try to hit * you */ const char wizapp[] = "@DNPTUVXcemntx"; /* If he has found the Amulet, make the wizard appear after some time */ void amulet() { struct obj *otmp; struct monst *mtmp; if (!flags.made_amulet || !flags.no_of_wizards) return; /* find wizard, and wake him if necessary */ for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp->data->mlet == '1' && mtmp->msleep && !rn2(40)) for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp->olet == AMULET_SYM && !otmp->spe) { mtmp->msleep = 0; if (dist(mtmp->mx, mtmp->my) > 2) pline( "You get the creepy feeling that somebody noticed your taking the Amulet." ); return; } } int wiz_hit(mtmp) struct monst *mtmp; { /* if we have stolen or found the amulet, we disappear */ if (mtmp->minvent && mtmp->minvent->olet == AMULET_SYM && mtmp->minvent->spe == 0) { /* vanish -- very primitive */ fall_down(mtmp); return (1); } /* if it is lying around someplace, we teleport to it */ if (!carrying(AMULET_OF_YENDOR)) { struct obj *otmp; for (otmp = fobj; otmp; otmp = otmp->nobj) if (otmp->olet == AMULET_SYM && !otmp->spe) { if ((u.ux != otmp->ox || u.uy != otmp->oy) && !m_at(otmp->ox, otmp->oy)) { /* teleport to it and pick it up */ mtmp->mx = otmp->ox; mtmp->my = otmp->oy; freeobj(otmp); mpickobj(mtmp, otmp); pmon(mtmp); return (0); } goto hithim; } return (0); /* we don't know where it is */ } hithim: if (rn2(2)) { /* hit - perhaps steal */ /* * if hit 1/20 chance of stealing amulet & vanish - amulet is * on level 26 again. */ if (hitu(mtmp, d(mtmp->data->damn, mtmp->data->damd)) && !rn2(20) && stealamulet(mtmp)) (void)0; } else inrange(mtmp); /* try magic */ return (0); } void inrange(mtmp) struct monst *mtmp; { schar tx, ty; /* do nothing if cancelled (but make '1' say something) */ if (mtmp->data->mlet != '1' && mtmp->mcan) return; /* spit fire only when both in a room or both in a corridor */ if (inroom(u.ux, u.uy) != inroom(mtmp->mx, mtmp->my)) return; tx = u.ux - mtmp->mx; ty = u.uy - mtmp->my; if ((!tx && abs(ty) < BOLT_LIM) || (!ty && abs(tx) < BOLT_LIM) || (abs(tx) == abs(ty) && abs(tx) < BOLT_LIM)) { switch (mtmp->data->mlet) { case 'D': /* spit fire in the direction of @ (not nec. hitting) */ buzz(-1, mtmp->mx, mtmp->my, sgn(tx), sgn(ty)); break; case '1': if (rn2(WIZSHOT)) break; /* * if you zapped wizard with wand of cancellation, he * has to shake off the effects before he can throw * spells successfully. 1/2 the time they fail * anyway */ if (mtmp->mcan || rn2(2)) { if (canseemon(mtmp)) pline("%s makes a gesture, then curses.", Monnam(mtmp)); else pline("You hear mumbled cursing."); if (!rn2(3)) { mtmp->mspeed = 0; mtmp->minvis = 0; } if (!rn2(3)) mtmp->mcan = 0; } else { if (canseemon(mtmp)) { if (!rn2(6) && !Invis) { pline("%s hypnotizes you.", Monnam(mtmp)); nomul(rn2(3) + 3); break; } else pline("%s chants an incantation.", Monnam(mtmp)); } else pline("You hear a mumbled incantation."); switch (rn2(Invis ? 5 : 6)) { case 0: /* * create a nasty monster from a deep * level */ /* * (for the moment, 'nasty' is not * implemented) */ (void) makemon((struct permonst *) 0, u.ux, u.uy); break; case 1: pline("\"Destroy the thief, my pets!\""); aggravate(); /* aggravate all the * monsters */ /* fall into next case */ case 2: if (flags.no_of_wizards == 1 && rnd(5) == 0) /* * if only 1 wizard, clone * himself */ clonewiz(mtmp); break; case 3: if (mtmp->mspeed == MSLOW) mtmp->mspeed = 0; else mtmp->mspeed = MFAST; break; case 4: mtmp->minvis = 1; break; case 5: /* Only if not Invisible */ pline("You hear a clap of thunder!"); /* * shoot a bolt of fire or cold, or a * sleep ray */ buzz(-rnd(3), mtmp->mx, mtmp->my, sgn(tx), sgn(ty)); break; } } } if (u.uhp < 1) done_in_by(mtmp); } } void aggravate() { struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { mtmp->msleep = 0; if (mtmp->mfroz && !rn2(5)) mtmp->mfroz = 0; } } void clonewiz(mtmp) struct monst *mtmp; { struct monst *mtmp2; if ((mtmp2 = makemon(PM_WIZARD, mtmp->mx, mtmp->my)) != NULL) { flags.no_of_wizards = 2; unpmon(mtmp2); mtmp2->mappearance = wizapp[rn2(sizeof(wizapp) - 1)]; pmon(mtmp); } } bsd-games-2.17/hack/def.mkroom.h0000664000175000017500000000732507767741711015147 0ustar jsm28jsm28/* $NetBSD: def.mkroom.h,v 1.5 2003/04/02 18:36:34 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_MKROOM_H_ #define _DEF_MKROOM_H_ struct mkroom { schar lx,hx,ly,hy; /* usually xchar, but hx may be -1 */ schar rtype,rlit,doorct,fdoor; }; #define MAXNROFROOMS 15 extern struct mkroom rooms[MAXNROFROOMS+1]; #define DOORMAX 100 extern coord doors[DOORMAX]; /* various values of rtype */ /* 0: ordinary room; 8-15: various shops */ /* Note: some code assumes that >= 8 means shop, so be careful when adding new roomtypes */ #define SWAMP 3 #define VAULT 4 #define BEEHIVE 5 #define MORGUE 6 #define ZOO 7 #define SHOPBASE 8 #define WANDSHOP 9 #define GENERAL 15 #endif /* _DEF_MKROOM_H_ */ bsd-games-2.17/hack/hack.invent.c0000664000175000017500000005504510005547567015303 0ustar jsm28jsm28/* $NetBSD: hack.invent.c,v 1.9 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.invent.c,v 1.9 2004/01/27 20:30:29 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" #ifndef NOWORM #include "def.wseg.h" #endif /* NOWORM */ #define NOINVSYM '#' static int lastinvnr = 51; /* 0 ... 51 */ static void assigninvlet(struct obj *); static char *xprname(struct obj *, char); static void assigninvlet(otmp) struct obj *otmp; { boolean inuse[52]; int i; struct obj *obj; for (i = 0; i < 52; i++) inuse[i] = FALSE; for (obj = invent; obj; obj = obj->nobj) if (obj != otmp) { i = obj->invlet; if ('a' <= i && i <= 'z') inuse[i - 'a'] = TRUE; else if ('A' <= i && i <= 'Z') inuse[i - 'A' + 26] = TRUE; if (i == otmp->invlet) otmp->invlet = 0; } if ((i = otmp->invlet) && (('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z'))) return; for (i = lastinvnr + 1; i != lastinvnr; i++) { if (i == 52) { i = -1; continue; } if (!inuse[i]) break; } otmp->invlet = (inuse[i] ? NOINVSYM : (i < 26) ? ('a' + i) : ('A' + i - 26)); lastinvnr = i; } struct obj * addinv(obj) struct obj *obj; { struct obj *otmp; /* merge or attach to end of chain */ if (!invent) { invent = obj; otmp = 0; } else for (otmp = invent; /* otmp */ ; otmp = otmp->nobj) { if (merged(otmp, obj, 0)) return (otmp); if (!otmp->nobj) { otmp->nobj = obj; break; } } obj->nobj = 0; if (flags.invlet_constant) { assigninvlet(obj); /* * The ordering of the chain is nowhere significant * so in case you prefer some other order than the * historical one, change the code below. */ if (otmp) { /* find proper place in chain */ otmp->nobj = 0; if ((invent->invlet ^ 040) > (obj->invlet ^ 040)) { obj->nobj = invent; invent = obj; } else for (otmp = invent;; otmp = otmp->nobj) { if (!otmp->nobj || (otmp->nobj->invlet ^ 040) > (obj->invlet ^ 040)) { obj->nobj = otmp->nobj; otmp->nobj = obj; break; } } } } return (obj); } void useup(obj) struct obj *obj; { if (obj->quan > 1) { obj->quan--; obj->owt = weight(obj); } else { setnotworn(obj); freeinv(obj); obfree(obj, (struct obj *) 0); } } void freeinv(obj) struct obj *obj; { struct obj *otmp; if (obj == invent) invent = invent->nobj; else { for (otmp = invent; otmp->nobj != obj; otmp = otmp->nobj) if (!otmp->nobj) panic("freeinv"); otmp->nobj = obj->nobj; } } /* destroy object in fobj chain (if unpaid, it remains on the bill) */ void delobj(obj) struct obj *obj; { freeobj(obj); unpobj(obj); obfree(obj, (struct obj *) 0); } /* unlink obj from chain starting with fobj */ void freeobj(obj) struct obj *obj; { struct obj *otmp; if (obj == fobj) fobj = fobj->nobj; else { for (otmp = fobj; otmp->nobj != obj; otmp = otmp->nobj) if (!otmp) panic("error in freeobj"); otmp->nobj = obj->nobj; } } /* Note: freegold throws away its argument! */ void freegold(gold) struct gold *gold; { struct gold *gtmp; if (gold == fgold) fgold = gold->ngold; else { for (gtmp = fgold; gtmp->ngold != gold; gtmp = gtmp->ngold) if (!gtmp) panic("error in freegold"); gtmp->ngold = gold->ngold; } free((char *) gold); } void deltrap(trap) struct trap *trap; { struct trap *ttmp; if (trap == ftrap) ftrap = ftrap->ntrap; else { for (ttmp = ftrap; ttmp->ntrap != trap; ttmp = ttmp->ntrap); ttmp->ntrap = trap->ntrap; } free((char *) trap); } struct wseg *m_atseg; struct monst * m_at(x, y) int x, y; { struct monst *mtmp; #ifndef NOWORM struct wseg *wtmp; #endif /* NOWORM */ m_atseg = 0; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (mtmp->mx == x && mtmp->my == y) return (mtmp); #ifndef NOWORM if (mtmp->wormno) { for (wtmp = wsegs[mtmp->wormno]; wtmp; wtmp = wtmp->nseg) if (wtmp->wx == x && wtmp->wy == y) { m_atseg = wtmp; return (mtmp); } } #endif /* NOWORM */ } return (0); } struct obj * o_at(x, y) int x, y; { struct obj *otmp; for (otmp = fobj; otmp; otmp = otmp->nobj) if (otmp->ox == x && otmp->oy == y) return (otmp); return (0); } struct obj * sobj_at(n, x, y) int n, x, y; { struct obj *otmp; for (otmp = fobj; otmp; otmp = otmp->nobj) if (otmp->ox == x && otmp->oy == y && otmp->otyp == n) return (otmp); return (0); } int carried(obj) struct obj *obj; { struct obj *otmp; for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp == obj) return (1); return (0); } int carrying(type) int type; { struct obj *otmp; for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp->otyp == type) return (TRUE); return (FALSE); } struct obj * o_on(id, objchn) unsigned int id; struct obj *objchn; { while (objchn) { if (objchn->o_id == id) return (objchn); objchn = objchn->nobj; } return ((struct obj *) 0); } struct trap * t_at(x, y) int x, y; { struct trap *trap = ftrap; while (trap) { if (trap->tx == x && trap->ty == y) return (trap); trap = trap->ntrap; } return (0); } struct gold * g_at(x, y) int x, y; { struct gold *gold = fgold; while (gold) { if (gold->gx == x && gold->gy == y) return (gold); gold = gold->ngold; } return (0); } /* make dummy object structure containing gold - for temporary use only */ struct obj * mkgoldobj(q) long q; { struct obj *otmp; otmp = newobj(0); /* should set o_id etc. but otmp will be freed soon */ otmp->olet = '$'; u.ugold -= q; OGOLD(otmp) = q; flags.botl = 1; return (otmp); } /* * getobj returns: * struct obj *xxx: object to do something with. * (struct obj *) 0 error return: no object. * &zeroobj explicitly no object (as in w-). */ struct obj * getobj(let, word) const char *let, *word; { struct obj *otmp; char ilet, ilet1, ilet2; char buf[BUFSZ]; char lets[BUFSZ]; int foo = 0, foo2; char *bp = buf; xchar allowcnt = 0; /* 0, 1 or 2 */ boolean allowgold = FALSE; boolean allowall = FALSE; boolean allownone = FALSE; xchar foox = 0; long cnt; if (*let == '0') let++, allowcnt = 1; if (*let == '$') let++, allowgold = TRUE; if (*let == '#') let++, allowall = TRUE; if (*let == '-') let++, allownone = TRUE; if (allownone) *bp++ = '-'; if (allowgold) *bp++ = '$'; if (bp > buf && bp[-1] == '-') *bp++ = ' '; ilet = 'a'; for (otmp = invent; otmp; otmp = otmp->nobj) { if (!*let || strchr(let, otmp->olet)) { bp[foo++] = flags.invlet_constant ? otmp->invlet : ilet; /* ugly check: remove inappropriate things */ if ((!strcmp(word, "take off") && !(otmp->owornmask & (W_ARMOR - W_ARM2))) || (!strcmp(word, "wear") && (otmp->owornmask & (W_ARMOR | W_RING))) || (!strcmp(word, "wield") && (otmp->owornmask & W_WEP))) { foo--; foox++; } } if (ilet == 'z') ilet = 'A'; else ilet++; } bp[foo] = 0; if (foo == 0 && bp > buf && bp[-1] == ' ') *--bp = 0; (void) strcpy(lets, bp);/* necessary since we destroy buf */ if (foo > 5) { /* compactify string */ foo = foo2 = 1; ilet2 = bp[0]; ilet1 = bp[1]; while ((ilet = bp[++foo2] = bp[++foo]) != '\0') { if (ilet == ilet1 + 1) { if (ilet1 == ilet2 + 1) bp[foo2 - 1] = ilet1 = '-'; else if (ilet2 == '-') { bp[--foo2] = ++ilet1; continue; } } ilet2 = ilet1; ilet1 = ilet; } } if (!foo && !allowall && !allowgold && !allownone) { pline("You don't have anything %sto %s.", foox ? "else " : "", word); return (0); } for (;;) { if (!buf[0]) pline("What do you want to %s [*]? ", word); else pline("What do you want to %s [%s or ?*]? ", word, buf); cnt = 0; ilet = readchar(); while (digit(ilet) && allowcnt) { if (cnt < 100000000) cnt = 10 * cnt + (ilet - '0'); else cnt = 999999999; allowcnt = 2; /* signal presence of cnt */ ilet = readchar(); } if (digit(ilet)) { pline("No count allowed with this command."); continue; } if (strchr(quitchars, ilet)) return ((struct obj *) 0); if (ilet == '-') { return (allownone ? &zeroobj : (struct obj *) 0); } if (ilet == '$') { if (!allowgold) { pline("You cannot %s gold.", word); continue; } if (!(allowcnt == 2 && cnt < u.ugold)) cnt = u.ugold; return (mkgoldobj(cnt)); } if (ilet == '?') { doinv(lets); if (!(ilet = morc)) continue; /* he typed a letter (not a space) to more() */ } else if (ilet == '*') { doinv((char *) 0); if (!(ilet = morc)) continue; /* ... */ } if (flags.invlet_constant) { for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp->invlet == ilet) break; } else { if (ilet >= 'A' && ilet <= 'Z') ilet += 'z' - 'A' + 1; ilet -= 'a'; for (otmp = invent; otmp && ilet; ilet--, otmp = otmp->nobj); } if (!otmp) { pline("You don't have that object."); continue; } if (cnt < 0 || otmp->quan < cnt) { pline("You don't have that many! [You have %u]" ,otmp->quan); continue; } break; } if (!allowall && let && !strchr(let, otmp->olet)) { pline("That is a silly thing to %s.", word); return (0); } if (allowcnt == 2) { /* cnt given */ if (cnt == 0) return (0); if (cnt != otmp->quan) { struct obj *obj; obj = splitobj(otmp, (int) cnt); if (otmp == uwep) setuwep(obj); } } return (otmp); } int ckunpaid(otmp) struct obj *otmp; { return (otmp->unpaid); } /* interactive version of getobj - used for Drop and Identify */ /* return the number of times fn was called successfully */ int ggetobj(word, fn, max) const char *word; int (*fn)(struct obj *); int max; { char buf[BUFSZ]; char *ip; char sym; int oletct = 0, iletct = 0; boolean allflag = FALSE; char olets[20], ilets[20]; int (*ckfn)(struct obj *) = (int (*)(struct obj *)) 0; xchar allowgold = (u.ugold && !strcmp(word, "drop")) ? 1 : 0; /* BAH */ if (!invent && !allowgold) { pline("You have nothing to %s.", word); return (0); } else { struct obj *otmp = invent; int uflg = 0; if (allowgold) ilets[iletct++] = '$'; ilets[iletct] = 0; while (otmp) { if (!strchr(ilets, otmp->olet)) { ilets[iletct++] = otmp->olet; ilets[iletct] = 0; } if (otmp->unpaid) uflg = 1; otmp = otmp->nobj; } ilets[iletct++] = ' '; if (uflg) ilets[iletct++] = 'u'; if (invent) ilets[iletct++] = 'a'; ilets[iletct] = 0; } pline("What kinds of thing do you want to %s? [%s] ", word, ilets); getlin(buf); if (buf[0] == '\033') { clrlin(); return (0); } ip = buf; olets[0] = 0; while ((sym = *ip++) != '\0') { if (sym == ' ') continue; if (sym == '$') { if (allowgold == 1) (*fn) (mkgoldobj(u.ugold)); else if (!u.ugold) pline("You have no gold."); allowgold = 2; } else if (sym == 'a' || sym == 'A') allflag = TRUE; else if (sym == 'u' || sym == 'U') ckfn = ckunpaid; else if (strchr("!%?[()=*/\"0", sym)) { if (!strchr(olets, sym)) { olets[oletct++] = sym; olets[oletct] = 0; } } else pline("You don't have any %c's.", sym); } if (allowgold == 2 && !oletct) return (1); /* he dropped gold (or at least tried to) */ else return (askchain(invent, olets, allflag, fn, ckfn, max)); } /* * Walk through the chain starting at objchn and ask for all objects * with olet in olets (if nonNULL) and satisfying ckfn (if nonNULL) * whether the action in question (i.e., fn) has to be performed. * If allflag then no questions are asked. Max gives the max nr of * objects to be treated. Return the number of objects treated. */ int askchain(objchn, olets, allflag, fn, ckfn, max) struct obj *objchn; char *olets; int allflag; int (*fn)(struct obj *); int (*ckfn)(struct obj *); int max; { struct obj *otmp, *otmp2; char sym, ilet; int cnt = 0; ilet = 'a' - 1; for (otmp = objchn; otmp; otmp = otmp2) { if (ilet == 'z') ilet = 'A'; else ilet++; otmp2 = otmp->nobj; if (olets && *olets && !strchr(olets, otmp->olet)) continue; if (ckfn && !(*ckfn) (otmp)) continue; if (!allflag) { pline(xprname(otmp, ilet)); addtopl(" [nyaq]? "); sym = readchar(); } else sym = 'y'; switch (sym) { case 'a': allflag = 1; case 'y': cnt += (*fn) (otmp); if (--max == 0) goto ret; case 'n': default: break; case 'q': goto ret; } } pline(cnt ? "That was all." : "No applicable objects."); ret: return (cnt); } char obj_to_let(obj) /* should of course only be called for things * in invent */ struct obj *obj; { struct obj *otmp; char ilet; if (flags.invlet_constant) return (obj->invlet); ilet = 'a'; for (otmp = invent; otmp && otmp != obj; otmp = otmp->nobj) if (++ilet > 'z') ilet = 'A'; return (otmp ? ilet : NOINVSYM); } void prinv(obj) struct obj *obj; { pline(xprname(obj, obj_to_let(obj))); } static char * xprname(obj, let) struct obj *obj; char let; { static char li[BUFSZ]; (void) sprintf(li, "%c - %s.", flags.invlet_constant ? obj->invlet : let, doname(obj)); return (li); } int ddoinv() { doinv((char *) 0); return (0); } /* called with 0 or "": all objects in inventory */ /* otherwise: all objects with (serial) letter in lets */ void doinv(lets) char *lets; { struct obj *otmp; char ilet; int ct = 0; char any[BUFSZ]; morc = 0; /* just to be sure */ if (!invent) { pline("Not carrying anything."); return; } cornline(0, (char *) 0); ilet = 'a'; for (otmp = invent; otmp; otmp = otmp->nobj) { if (flags.invlet_constant) ilet = otmp->invlet; if (!lets || !*lets || strchr(lets, ilet)) { cornline(1, xprname(otmp, ilet)); any[ct++] = ilet; } if (!flags.invlet_constant) if (++ilet > 'z') ilet = 'A'; } any[ct] = 0; cornline(2, any); } int dotypeinv() { /* free after Robert Viduya */ /* Changed to one type only, so he doesnt have to type cr */ char c, ilet; char stuff[BUFSZ]; int stct; struct obj *otmp; boolean billx = inshop() && doinvbill(0); boolean unpd = FALSE; if (!invent && !u.ugold && !billx) { pline("You aren't carrying anything."); return (0); } stct = 0; if (u.ugold) stuff[stct++] = '$'; stuff[stct] = 0; for (otmp = invent; otmp; otmp = otmp->nobj) { if (!strchr(stuff, otmp->olet)) { stuff[stct++] = otmp->olet; stuff[stct] = 0; } if (otmp->unpaid) unpd = TRUE; } if (unpd) stuff[stct++] = 'u'; if (billx) stuff[stct++] = 'x'; stuff[stct] = 0; if (stct > 1) { pline("What type of object [%s] do you want an inventory of? ", stuff); c = readchar(); if (strchr(quitchars, c)) return (0); } else c = stuff[0]; if (c == '$') return (doprgold()); if (c == 'x' || c == 'X') { if (billx) (void) doinvbill(1); else pline("No used-up objects on the shopping bill."); return (0); } if ((c == 'u' || c == 'U') && !unpd) { pline("You are not carrying any unpaid objects."); return (0); } stct = 0; ilet = 'a'; for (otmp = invent; otmp; otmp = otmp->nobj) { if (flags.invlet_constant) ilet = otmp->invlet; if (c == otmp->olet || (c == 'u' && otmp->unpaid)) stuff[stct++] = ilet; if (!flags.invlet_constant) if (++ilet > 'z') ilet = 'A'; } stuff[stct] = '\0'; if (stct == 0) pline("You have no such objects."); else doinv(stuff); return (0); } /* look at what is here */ int dolook() { struct obj *otmp = NULL, *otmp0 = NULL; struct gold *gold = NULL; const char *verb = Blind ? "feel" : "see"; int ct = 0; if (!u.uswallow) { if (Blind) { pline("You try to feel what is lying here on the floor."); if (Levitation) { /* ab@unido */ pline("You cannot reach the floor!"); return (1); } } otmp0 = o_at(u.ux, u.uy); gold = g_at(u.ux, u.uy); } if (u.uswallow || (!otmp0 && !gold)) { pline("You %s no objects here.", verb); return (!!Blind); } cornline(0, "Things that are here:"); for (otmp = otmp0; otmp; otmp = otmp->nobj) { if (otmp->ox == u.ux && otmp->oy == u.uy) { ct++; cornline(1, doname(otmp)); if (Blind && otmp->otyp == DEAD_COCKATRICE && !uarmg) { pline("Touching the dead cockatrice is a fatal mistake ..."); pline("You die ..."); killer = "dead cockatrice"; done("died"); } } } if (gold) { char gbuf[30]; (void) sprintf(gbuf, "%ld gold piece%s", gold->amount, plur(gold->amount)); if (!ct++) pline("You %s here %s.", verb, gbuf); else cornline(1, gbuf); } if (ct == 1 && !gold) { pline("You %s here %s.", verb, doname(otmp0)); cornline(3, (char *) 0); } if (ct > 1) cornline(2, (char *) 0); return (!!Blind); } void stackobj(obj) struct obj *obj; { struct obj *otmp = fobj; for (otmp = fobj; otmp; otmp = otmp->nobj) if (otmp != obj) if (otmp->ox == obj->ox && otmp->oy == obj->oy && merged(obj, otmp, 1)) return; } /* merge obj with otmp and delete obj if types agree */ int merged(otmp, obj, lose) struct obj *otmp, *obj; int lose; { if (obj->otyp == otmp->otyp && obj->unpaid == otmp->unpaid && obj->spe == otmp->spe && obj->dknown == otmp->dknown && obj->cursed == otmp->cursed && (strchr("%*?!", obj->olet) || (obj->known == otmp->known && (obj->olet == WEAPON_SYM && obj->otyp < BOOMERANG)))) { otmp->quan += obj->quan; otmp->owt += obj->owt; if (lose) freeobj(obj); obfree(obj, otmp); /* free(obj), bill->otmp */ return (1); } else return (0); } static long goldcounted; /* * Gold is no longer displayed; in fact, when you have a lot of money, * it may take a while before you have counted it all. * [Bug: d$ and pickup still tell you how much it was.] */ int countgold() { if ((goldcounted += 100 * (u.ulevel + 1)) >= u.ugold) { long eps = 0; if (!rn2(2)) eps = rnd((int) (u.ugold / 100 + 1)); pline("You probably have about %ld gold pieces.", u.ugold + eps); return (0); /* done */ } return (1); /* continue */ } int doprgold() { if (!u.ugold) pline("You do not carry any gold."); else if (u.ugold <= 500) pline("You are carrying %ld gold pieces.", u.ugold); else { pline("You sit down in order to count your gold pieces."); goldcounted = 500; occupation = countgold; occtxt = "counting your gold"; } return (1); } /* --- end of gold counting section --- */ int doprwep() { if (!uwep) pline("You are empty handed."); else prinv(uwep); return (0); } int doprarm() { if (!uarm && !uarmg && !uarms && !uarmh) pline("You are not wearing any armor."); else { char lets[6]; int ct = 0; if (uarm) lets[ct++] = obj_to_let(uarm); if (uarm2) lets[ct++] = obj_to_let(uarm2); if (uarmh) lets[ct++] = obj_to_let(uarmh); if (uarms) lets[ct++] = obj_to_let(uarms); if (uarmg) lets[ct++] = obj_to_let(uarmg); lets[ct] = 0; doinv(lets); } return (0); } int doprring() { if (!uleft && !uright) pline("You are not wearing any rings."); else { char lets[3]; int ct = 0; if (uleft) lets[ct++] = obj_to_let(uleft); if (uright) lets[ct++] = obj_to_let(uright); lets[ct] = 0; doinv(lets); } return (0); } int digit(c) char c; { return (c >= '0' && c <= '9'); } bsd-games-2.17/hack/def.trap.h0000664000175000017500000000731107767741711014604 0ustar jsm28jsm28/* $NetBSD: def.trap.h,v 1.5 2003/04/02 18:36:35 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_TRAP_H_ #define _DEF_TRAP_H_ struct trap { struct trap *ntrap; xchar tx,ty; unsigned ttyp:5; unsigned tseen:1; unsigned once:1; }; extern struct trap *ftrap; #define newtrap() (struct trap *) alloc(sizeof(struct trap)) /* various kinds of traps */ #define BEAR_TRAP 0 #define ARROW_TRAP 1 #define DART_TRAP 2 #define TRAPDOOR 3 #define TELEP_TRAP 4 #define PIT 5 #define SLP_GAS_TRAP 6 #define PIERC 7 #define MIMIC 8 /* used only in mklev.c */ #define TRAPNUM 9 /* if not less than 32, change sizeof(ttyp) */ /* see also mtrapseen (bit map) */ #endif /* _DEF_TRAP_H_ */ bsd-games-2.17/hack/hack.fix0000664000175000017500000000642507357566201014345 0ustar jsm28jsm28$NetBSD: hack.fix,v 1.3 2001/09/16 16:34:25 wiz Exp $ /***** unido:net.games.hack / ab / 7:23 pm Sep 13, 1985*/ Recently hack (1.0.3) crashed with core dumps during some good games. The crashes occurred in the onbill-routine. After investigating the core dump I found that the shopkeeper's bill was still to be paid. Normaly if you leave a shop the bill will be cleared and onbill() would not check it. But under certain conditions you can leave a shop without clearing the bill. The conditions are: 1. You have to rob a shop in order to make the shopkeeper follow you. 2. After leaving the shop being followed by the shopkeeper you must return to the shop... 3. ...and then leave the unguarded shop again. - The shopkeeper mustn't be present! If you climb the stairs to the previous level, chances are that your bill now contains much more items than allowed. If so the next call to onbill() will dump the core. Following is a context diff to fix the bug. Actually just the last hunk does the fix [it deletes two lines which have been inserted in 1.0.3], but I think the other fix was intended by the now deleted lines. Andreas -- Andreas Bormann ab@unido.UUCP University of Dortmund N 51 29' 05" E 07 24' 42" West Germany ------ the diff follows: *** hack.shk.c.orig Sun Aug 4 12:07:51 1985 --- hack.shk.c Fri Sep 13 14:29:52 1985 *************** *** 133,139 /* Did we just leave a shop? */ if(u.uinshop && (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) { - u.uinshop = 0; if(shopkeeper) { if(ESHK(shopkeeper)->billct) { pline("Somehow you escaped the shop without paying!"); --- 133,138 ----- /* Did we just leave a shop? */ if(u.uinshop && (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) { if(shopkeeper) { if(ESHK(shopkeeper)->billct) { if(inroom(shopkeeper->mx, shopkeeper->my) *************** *** 136,142 u.uinshop = 0; if(shopkeeper) { if(ESHK(shopkeeper)->billct) { ! pline("Somehow you escaped the shop without paying!"); addupbill(); pline("You stole for a total worth of %ld zorkmids.", total); --- 135,143 ----- (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) { if(shopkeeper) { if(ESHK(shopkeeper)->billct) { ! if(inroom(shopkeeper->mx, shopkeeper->my) ! == u.uinshop - 1) /* ab@unido */ ! pline("Somehow you escaped the shop without paying!"); addupbill(); pline("You stole for a total worth of %ld zorkmids.", total); *************** *** 149,154 shopkeeper = 0; shlevel = 0; } } /* Did we just enter a zoo of some kind? */ --- 150,156 ----- shopkeeper = 0; shlevel = 0; } + u.uinshop = 0; } /* Did we just enter a zoo of some kind? */ *************** *** 183,190 findshk(roomno); if(!shopkeeper) { rooms[roomno].rtype = 0; - u.uinshop = 0; - } else if(inroom(shopkeeper->mx, shopkeeper->my) != roomno) { u.uinshop = 0; } else if(!u.uinshop){ if(!ESHK(shopkeeper)->visitct || --- 185,190 ----- findshk(roomno); if(!shopkeeper) { rooms[roomno].rtype = 0; u.uinshop = 0; } else if(!u.uinshop){ if(!ESHK(shopkeeper)->visitct || /* ---------- */ bsd-games-2.17/hack/config.h0000664000175000017500000001725207767741711014353 0ustar jsm28jsm28/* $NetBSD: config.h,v 1.7 2003/04/02 18:36:33 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "pathnames.h" #ifndef CONFIG /* make sure the compiler doesnt see the typedefs twice */ #define CONFIG #define UNIX /* delete if no fork(), exec() available */ #define CHDIR /* delete if no chdir() available */ /* * Some include files are in a different place under SYSV * BSD SYSV * * * * Some routines are called differently * index strchr * rindex strrchr * Also, the code for suspend and various ioctls is only given for BSD4.2 * (I do not have access to a SYSV system.) */ #define BSD /* delete this line on System V */ /* #define STUPID */ /* avoid some complicated expressions if your C compiler chokes on them */ /* #define PYRAMID_BUG */ /* avoid a bug on the Pyramid */ /* #define NOWAITINCLUDE */ /* neither nor exists */ #define WIZARD "bruno" /* the person allowed to use the -D option */ #define RECORD "record"/* the file containing the list of topscorers */ #define NEWS "news" /* the file containing the latest hack news */ #define HELP "help" /* the file containing a description of the commands */ #define SHELP "hh" /* abbreviated form of the same */ #define RUMORFILE "rumors" /* a file with fortune cookies */ #define DATAFILE "data" /* a file giving the meaning of symbols used */ #define FMASK 0660 /* file creation mask */ #define HLOCK "perm" /* an empty file used for locking purposes */ #define LLOCK "safelock" /* link to previous */ #ifdef UNIX /* * Define DEF_PAGER as your default pager, e.g. "/bin/cat" or "/usr/ucb/more" * If defined, it can be overridden by the environment variable PAGER. * Hack will use its internal pager if DEF_PAGER is not defined. * (This might be preferable for security reasons.) * #define DEF_PAGER ".../mydir/mypager" */ /* * If you define MAIL, then the player will be notified of new mail * when it arrives. If you also define DEF_MAILREADER then this will * be the default mail reader, and can be overridden by the environment * variable MAILREADER; otherwise an internal pager will be used. * A stat system call is done on the mailbox every MAILCKFREQ moves. */ /* #define MAIL */ #define DEF_MAILREADER _PATH_MAIL /* or e.g. /bin/mail */ #define MAILCKFREQ 100 #define SHELL /* do not delete the '!' command */ #ifdef BSD #define SUSPEND /* let ^Z suspend the game */ #endif /* BSD */ #endif /* UNIX */ #ifdef CHDIR /* * If you define HACKDIR, then this will be the default playground; * otherwise it will be the current directory. */ #ifdef QUEST #define HACKDIR _PATH_QUEST #else /* QUEST */ #define HACKDIR _PATH_HACK #endif /* QUEST */ /* * Some system administrators are stupid enough to make Hack suid root * or suid daemon, where daemon has other powers besides that of reading or * writing Hack files. In such cases one should be careful with chdir's * since the user might create files in a directory of his choice. * Of course SECURE is meaningful only if HACKDIR is defined. */ #define SECURE /* do setuid(getuid()) after chdir() */ /* * If it is desirable to limit the number of people that can play Hack * simultaneously, define HACKDIR, SECURE and MAX_NR_OF_PLAYERS. * #define MAX_NR_OF_PLAYERS 100 */ #endif /* CHDIR */ /* size of terminal screen is (at least) (ROWNO+2) by COLNO */ #define COLNO 80 #define ROWNO 22 /* * small signed integers (8 bits suffice) * typedef char schar; * will do when you have signed characters; otherwise use * typedef short int schar; * * Use short chars anyway to avoid warnings. */ #if 1 typedef short int schar; #else typedef char schar; #endif /* * small unsigned integers (8 bits suffice - but 7 bits do not) * - these are usually object types; be careful with inequalities! - * typedef unsigned char uchar; * will be satisfactory if you have an "unsigned char" type; otherwise use * typedef unsigned short int uchar; */ typedef unsigned char uchar; /* * small integers in the range 0 - 127, usually coordinates * although they are nonnegative they must not be declared unsigned * since otherwise comparisons with signed quantities are done incorrectly */ typedef schar xchar; typedef xchar boolean; /* 0 or 1 */ #define TRUE 1 #define FALSE 0 /* * Declaration of bitfields in various structs; if your C compiler * doesnt handle bitfields well, e.g., if it is unable to initialize * structs containing bitfields, then you might use * #define Bitfield(x,n) uchar x * since the bitfields used never have more than 7 bits. (Most have 1 bit.) */ #define Bitfield(x,n) unsigned x:n #define SIZE(x) (int)(sizeof(x) / sizeof(x[0])) #endif /* CONFIG */ bsd-games-2.17/hack/extern.h0000664000175000017500000004105310005547567014377 0ustar jsm28jsm28/* $NetBSD: extern.h,v 1.6 2004/01/27 20:30:29 jsm Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _EXTERN_H_ #define _EXTERN_H_ #include #include /* alloc.c */ long *alloc(unsigned); long *enlarge(char *, unsigned); /* hack.apply.c */ int doapply(void); int holetime(void); void dighole(void); /* hack.bones.c */ void savebones(void); int getbones(void); /* hack.c */ void unsee(void); void seeoff(int); void domove(void); void movobj(struct obj *, int, int); int dopickup(void); void pickup(int); void lookaround(void); int monster_nearby(void); int rroom(int, int); int cansee(xchar, xchar); int sgn(int); void setsee(void); void nomul(int); int abon(void); int dbon(void); void losestr(int); void losehp(int, const char *); void losehp_m(int, struct monst *); void losexp(void); int inv_weight(void); int inv_cnt(void); long newuexp(void); /* hack.cmd.c */ void rhack(const char *); int doextcmd(void); char lowc(int); char unctrl(int); int movecmd(int); int getdir(boolean); void confdir(void); int finddir(void); int isroom(int, int); int isok(int, int); /* hack.do.c */ int dodrop(void); void dropx(struct obj *); void dropy(struct obj *); int doddrop(void); int dodown(void); int doup(void); void goto_level(int, boolean); int donull(void); int dopray(void); int dothrow(void); struct obj *splitobj(struct obj *, int); void more_experienced(int, int); void set_wounded_legs(long, int); void heal_legs(void); /* hack.do_name.c */ coord getpos(int, const char *); int do_mname(void); void do_oname(struct obj *); int ddocall(void); void docall(struct obj *); char *xmonnam(struct monst *, int); char *lmonnam(struct monst *); char *monnam(struct monst *); char *Monnam(struct monst *); char *amonnam(struct monst *, const char *); char *Amonnam(struct monst *, const char *); char *Xmonnam(struct monst *); char *visctrl(int); /* hack.do_wear.c */ void off_msg(struct obj *); int doremarm(void); int doremring(void); int dorr(struct obj *); int cursed(struct obj *); int armoroff(struct obj *); int doweararm(void); int dowearring(void); void ringoff(struct obj *); void find_ac(void); void glibr(void); struct obj *some_armor(void); void corrode_armor(void); /* hack.dog.c */ void makedog(void); void initedog(struct monst *); void losedogs(void); void keepdogs(void); void fall_down(struct monst *); int dogfood(struct obj *); int dog_move(struct monst *, int); int inroom(xchar, xchar); int tamedog(struct monst *, struct obj *); /* hack.eat.c */ void init_uhunger(void); int opentin(void); int Meatdone(void); int doeat(void); void gethungry(void); void morehungry(int); void lesshungry(int); int unfaint(void); void newuhs(boolean); int poisonous(struct obj *); int eatcorpse(struct obj *); /* hack.end.c */ int dodone(void); void done1(int); void done_intr(int); void done_hangup(int); void done_in_by(struct monst *); void done(const char *); void topten(void); void outheader(void); struct toptenentry; int outentry(int, struct toptenentry *, int); char *itoa(int); const char *ordin(int); void clearlocks(void); void hangup(int) __attribute__((__noreturn__)); char *eos(char *); void charcat(char *, int); void prscore(int, char **); /* hack.engrave.c */ struct engr *engr_at(xchar, xchar); int sengr_at(const char *, xchar, xchar); void u_wipe_engr(int); void wipe_engr_at(xchar, xchar, xchar); void read_engr_at(int, int); void make_engr_at(int, int, const char *); int doengrave(void); void save_engravings(int); void rest_engravings(int); void del_engr(struct engr *); /* hack.fight.c */ int hitmm(struct monst *, struct monst *); void mondied(struct monst *); void monstone(struct monst *); int fightm(struct monst *); int thitu(int, int, const char *); boolean hmon(struct monst *, struct obj *, int); int attack(struct monst *); /* hack.invent.c */ struct obj *addinv(struct obj *); void useup(struct obj *); void freeinv(struct obj *); void delobj(struct obj *); void freeobj(struct obj *); void freegold(struct gold *); void deltrap(struct trap *); struct monst *m_at(int, int); struct obj *o_at(int, int); struct obj *sobj_at(int, int, int); int carried(struct obj *); int carrying(int); struct obj *o_on(unsigned int, struct obj *); struct trap *t_at(int, int); struct gold *g_at(int, int); struct obj *mkgoldobj(long); struct obj *getobj(const char *, const char *); int ckunpaid(struct obj *); int ggetobj(const char *, int (*fn)(struct obj *), int); int askchain(struct obj *, char *, int, int (*)(struct obj *), int (*)(struct obj *), int); char obj_to_let(struct obj *); void prinv(struct obj *); int ddoinv(void); void doinv(char *); int dotypeinv(void); int dolook(void); void stackobj(struct obj *); int merged(struct obj *, struct obj *, int); int countgold(void); int doprgold(void); int doprwep(void); int doprarm(void); int doprring(void); int digit(int); /* hack.ioctl.c */ void getioctls(void); void setioctls(void); int dosuspend(void); /* hack.lev.c */ void savelev(int, xchar); void bwrite(int, const void *, unsigned); void saveobjchn(int, struct obj *); void savemonchn(int, struct monst *); void savegoldchn(int, struct gold *); void savetrapchn(int, struct trap *); void getlev(int, int, xchar); void mread(int, char *, unsigned); void mklev(void); /* hack.main.c */ void glo(int); void askname(void); void impossible(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); void stop_occupation(void); /* hack.makemon.c */ struct monst *makemon(const struct permonst *, int, int); coord enexto(xchar, xchar); int goodpos(int, int); void rloc(struct monst *); struct monst *mkmon_at(int, int, int); /* hack.mhitu.c */ int mhitu(struct monst *); int hitu(struct monst *, int); /* hack.mklev.c */ void makelevel(void); int makerooms(void); void addrs(int, int, int, int); void addrsx(int, int, int, int, boolean); struct mkroom; int comp(const void *, const void *); coord finddpos(int, int, int, int); int okdoor(int, int); void dodoor(int, int, struct mkroom *); void dosdoor(int, int, struct mkroom *, int); int maker(schar, schar, schar, schar); void makecorridors(void); void join(int, int); void make_niches(void); void makevtele(void); void makeniche(boolean); void mktrap(int, int, struct mkroom *); /* hack.mkmaze.c */ void makemaz(void); void walkfrom(int, int); void move(int *, int *, int); int okay(int, int, int); coord mazexy(void); /* hack.mkobj.c */ struct obj *mkobj_at(int, int, int); void mksobj_at(int, int, int); struct obj *mkobj(int); struct obj *mksobj(int); int letter(int); int weight(struct obj *); void mkgold(long, int, int); /* hack.mkshop.c */ void mkshop(void); void mkzoo(int); const struct permonst *morguemon(void); void mkswamp(void); int nexttodoor(int, int); int has_dnstairs(struct mkroom *); int has_upstairs(struct mkroom *); int isbig(struct mkroom *); int dist2(int, int, int, int); int sq(int); /* hack.mon.c */ void movemon(void); void justswld(struct monst *, const char *); void youswld(struct monst *, int, int, const char *); int dochugw(struct monst *); int dochug(struct monst *); int m_move(struct monst *, int); void mpickgold(struct monst *); void mpickgems(struct monst *); int mfndpos(struct monst *, coord[9 ], int[9 ], int); int dist(int, int); void poisoned(const char *, const char *); void mondead(struct monst *); void replmon(struct monst *, struct monst *); void relmon(struct monst *); void monfree(struct monst *); void dmonsfree(void); void unstuck(struct monst *); void killed(struct monst *); void kludge(const char *, const char *); void rescham(void); int newcham(struct monst *, const struct permonst *); void mnexto(struct monst *); int ishuman(struct monst *); void setmangry(struct monst *); int canseemon(struct monst *); /* hack.monst.c */ /* hack.o_init.c */ int letindex(int); void init_objects(void); int probtype(int); void setgemprobs(void); void oinit(void); void savenames(int); void restnames(int); int dodiscovered(void); int interesting_to_discover(int); /* hack.objnam.c */ char *strprepend(char *, char *); char *sitoa(int); char *typename(int); char *xname(struct obj *); char *doname(struct obj *); void setan(const char *, char *); char *aobjnam(struct obj *, const char *); char *Doname(struct obj *); struct obj *readobjnam(char *); /* hack.options.c */ void initoptions(void); void parseoptions(char *, boolean); int doset(void); /* hack.pager.c */ int dowhatis(void); void intruph(int); void page_more(FILE *, int); void set_whole_screen(void); int readnews(void); void set_pager(int); int page_line(const char *); void cornline(int, const char *); int dohelp(void); int page_file(const char *, boolean); int dosh(void); int child(int); /* hack.potion.c */ int dodrink(void); void pluslvl(void); void strange_feeling(struct obj *, const char *); void potionhit(struct monst *, struct obj *); void potionbreathe(struct obj *); int dodip(void); void ghost_from_bottle(void); /* hack.pri.c */ void swallowed(void); void panic(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); void atl(int, int, int); void on_scr(int, int); void tmp_at(schar, schar); void Tmp_at(schar, schar); void setclipped(void) __attribute__((__noreturn__)); void at(xchar, xchar, int); void prme(void); int doredraw(void); void docrt(void); void docorner(int, int); void curs_on_u(void); void pru(void); void prl(int, int); char news0(xchar, xchar); void newsym(int, int); void mnewsym(int, int); void nosee(int, int); void prl1(int, int); void nose1(int, int); int vism_at(int, int); void pobj(struct obj *); void unpobj(struct obj *); void seeobjs(void); void seemons(void); void pmon(struct monst *); void unpmon(struct monst *); void nscr(void); void cornbot(int); void bot(void); void mstatusline(struct monst *); void cls(void); /* hack.read.c */ int doread(void); int identify(struct obj *); void litroom(boolean); int monstersym(int); /* hack.rip.c */ void outrip(void); void center(int, char *); /* hack.rumors.c */ void init_rumors(FILE *); int skipline(FILE *); void outline(FILE *); void outrumor(void); int used(int); /* hack.save.c */ int dosave(void); int dosave0(int); int dorecover(int); struct obj *restobjchn(int); struct monst *restmonchn(int); /* hack.search.c */ int findit(void); int dosearch(void); int doidtrap(void); void wakeup(struct monst *); void seemimic(struct monst *); /* hack.shk.c */ void obfree(struct obj *, struct obj *); void paybill(void); char *shkname(struct monst *); void shkdead(struct monst *); void replshk(struct monst *, struct monst *); int inshop(void); int dopay(void); struct bill_x; struct obj *bp_to_obj(struct bill_x *); void addtobill(struct obj *); void splitbill(struct obj *, struct obj *); void subfrombill(struct obj *); int doinvbill(int); int shkcatch(struct obj *); int shk_move(struct monst *); void shopdig(int); int online(int, int); int follower(struct monst *); /* hack.shknam.c */ void findname(char *, int); /* hack.steal.c */ long somegold(void); void stealgold(struct monst *); int stealarm(void); int steal(struct monst *); void mpickobj(struct monst *, struct obj *); int stealamulet(struct monst *); void relobj(struct monst *, int); /* hack.termcap.c */ void startup(void); void start_screen(void); void end_screen(void); void curs(int, int); void nocmov(int, int); void cmov(int, int); int xputc(int); void xputs(char *); void cl_end(void); void clear_screen(void); void home(void); void standoutbeg(void); void standoutend(void); void backsp(void); void bell(void); void delay_output(void); void cl_eos(void); /* hack.timeout.c */ void timeout(void); void stoned_dialogue(void); /* hack.topl.c */ int doredotopl(void); void redotoplin(void); void remember_topl(void); void addtopl(const char *); void xmore(const char *); void more(void); void cmore(const char *); void clrlin(void); void pline(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); void vpline(const char *, va_list) __attribute__((__format__(__printf__, 1, 0))); void putsym(int); void putstr(const char *); /* hack.track.c */ void initrack(void); void settrack(void); coord *gettrack(int, int); /* hack.trap.c */ struct trap *maketrap(int, int, int); void dotrap(struct trap *); int mintrap(struct monst *); void selftouch(const char *); void float_up(void); void float_down(void); void vtele(void); void tele(void); void teleds(int, int); int teleok(int, int); int dotele(void); void placebc(int); void unplacebc(void); void level_tele(void); void drown(void); /* hack.tty.c */ void gettty(void); void settty(const char *); void setctty(void); void setftty(void); void error(const char *, ...) __attribute__((__format__(__printf__, 1, 2),__noreturn__)); void getlin(char *); void getret(void); void cgetret(const char *); void xwaitforspace(const char *); char *parse(void); char readchar(void); void end_of_input(void) __attribute__((__noreturn__)); /* hack.u_init.c */ void u_init(void); struct trobj; void ini_inv(struct trobj *); void wiz_inv(void); void plnamesuffix(void); int role_index(int); /* hack.unix.c */ void setrandom(void); struct tm *getlt(void); int getyear(void); char *getdate(void); int phase_of_the_moon(void); int night(void); int midnight(void); void gethdate(char *); int uptodate(int); int veryold(int); void getlock(void); void getmailstatus(void); void ckmailstatus(void); void newmail(void); void mdrush(struct monst *, boolean); void readmail(void); void regularize(char *); /* hack.vault.c */ void setgd(void); int gd_move(void); void gddead(void); void replgd(struct monst *, struct monst *); void invault(void); /* hack.version.c */ int doversion(void); /* hack.wield.c */ void setuwep(struct obj *); int dowield(void); void corrode_weapon(void); int chwepon(struct obj *, int); /* hack.wizard.c */ void amulet(void); int wiz_hit(struct monst *); void inrange(struct monst *); void aggravate(void); void clonewiz(struct monst *); /* hack.worm.c */ #ifndef NOWORM int getwn(struct monst *); void initworm(struct monst *); void worm_move(struct monst *); void worm_nomove(struct monst *); void wormdead(struct monst *); void wormhit(struct monst *); void wormsee(unsigned); struct wseg; void pwseg(struct wseg *); void cutworm(struct monst *, xchar, xchar, uchar); void remseg(struct wseg *); #endif /* hack.worn.c */ void setworn(struct obj *, long); void setnotworn(struct obj *); /* hack.zap.c */ void bhitm(struct monst *, struct obj *); int bhito(struct obj *, struct obj *); int dozap(void); const char *exclam(int); void hit(const char *, struct monst *, const char *); void miss(const char *, struct monst *); struct monst *bhit(int, int, int, int, void (*)(struct monst *, struct obj *), int (*)(struct obj *, struct obj *), struct obj *); struct monst *boomhit(int, int); char dirlet(int, int); void buzz(int, xchar, xchar, int, int); int zhit(struct monst *, int); int revive(struct obj *); void rloco(struct obj *); void fracture_rock(struct obj *); void burn_scrolls(void); /* rnd.c */ int rn1(int, int); int rn2(int); int rnd(int); int d(int, int); #endif /* _EXTERN_H_ */ bsd-games-2.17/hack/hack.objnam.c0000664000175000017500000003545107767741711015255 0ustar jsm28jsm28/* $NetBSD: hack.objnam.c,v 1.6 2003/04/02 18:36:39 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.objnam.c,v 1.6 2003/04/02 18:36:39 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" #define Sprintf (void) sprintf #define Strcat (void) strcat #define Strcpy (void) strcpy #define PREFIX 15 char * strprepend(s, pref) char *s, *pref; { int i = strlen(pref); if (i > PREFIX) { pline("WARNING: prefix too short."); return (s); } s -= i; (void) strncpy(s, pref, i); /* do not copy trailing 0 */ return (s); } char * sitoa(a) int a; { static char buf[13]; Sprintf(buf, (a < 0) ? "%d" : "+%d", a); return (buf); } char * typename(otyp) int otyp; { static char buf[BUFSZ]; struct objclass *ocl = &objects[otyp]; const char *an = ocl->oc_name; const char *dn = ocl->oc_descr; char *un = ocl->oc_uname; int nn = ocl->oc_name_known; switch (ocl->oc_olet) { case POTION_SYM: Strcpy(buf, "potion"); break; case SCROLL_SYM: Strcpy(buf, "scroll"); break; case WAND_SYM: Strcpy(buf, "wand"); break; case RING_SYM: Strcpy(buf, "ring"); break; default: if (nn) { Strcpy(buf, an); if (otyp >= TURQUOISE && otyp <= JADE) Strcat(buf, " stone"); if (un) Sprintf(eos(buf), " called %s", un); if (dn) Sprintf(eos(buf), " (%s)", dn); } else { Strcpy(buf, dn ? dn : an); if (ocl->oc_olet == GEM_SYM) Strcat(buf, " gem"); if (un) Sprintf(eos(buf), " called %s", un); } return (buf); } /* here for ring/scroll/potion/wand */ if (nn) Sprintf(eos(buf), " of %s", an); if (un) Sprintf(eos(buf), " called %s", un); if (dn) Sprintf(eos(buf), " (%s)", dn); return (buf); } char * xname(obj) struct obj *obj; { static char bufr[BUFSZ]; char *buf = &(bufr[PREFIX]); /* leave room for "17 -3 " */ int nn = objects[obj->otyp].oc_name_known; const char *an = objects[obj->otyp].oc_name; const char *dn = objects[obj->otyp].oc_descr; char *un = objects[obj->otyp].oc_uname; int pl = (obj->quan != 1); if (!obj->dknown && !Blind) obj->dknown = 1;/* %% doesnt belong here */ switch (obj->olet) { case AMULET_SYM: Strcpy(buf, (obj->spe < 0 && obj->known) ? "cheap plastic imitation of the " : ""); Strcat(buf, "Amulet of Yendor"); break; case TOOL_SYM: if (!nn) { Strcpy(buf, dn); break; } Strcpy(buf, an); break; case FOOD_SYM: if (obj->otyp == DEAD_HOMUNCULUS && pl) { pl = 0; Strcpy(buf, "dead homunculi"); break; } /* fungis ? */ /* fall into next case */ case WEAPON_SYM: if (obj->otyp == WORM_TOOTH && pl) { pl = 0; Strcpy(buf, "worm teeth"); break; } if (obj->otyp == CRYSKNIFE && pl) { pl = 0; Strcpy(buf, "crysknives"); break; } /* fall into next case */ case ARMOR_SYM: case CHAIN_SYM: case ROCK_SYM: Strcpy(buf, an); break; case BALL_SYM: Sprintf(buf, "%sheavy iron ball", (obj->owt > objects[obj->otyp].oc_weight) ? "very " : ""); break; case POTION_SYM: if (nn || un || !obj->dknown) { Strcpy(buf, "potion"); if (pl) { pl = 0; Strcat(buf, "s"); } if (!obj->dknown) break; if (un) { Strcat(buf, " called "); Strcat(buf, un); } else { Strcat(buf, " of "); Strcat(buf, an); } } else { Strcpy(buf, dn); Strcat(buf, " potion"); } break; case SCROLL_SYM: Strcpy(buf, "scroll"); if (pl) { pl = 0; Strcat(buf, "s"); } if (!obj->dknown) break; if (nn) { Strcat(buf, " of "); Strcat(buf, an); } else if (un) { Strcat(buf, " called "); Strcat(buf, un); } else { Strcat(buf, " labeled "); Strcat(buf, dn); } break; case WAND_SYM: if (!obj->dknown) Sprintf(buf, "wand"); else if (nn) Sprintf(buf, "wand of %s", an); else if (un) Sprintf(buf, "wand called %s", un); else Sprintf(buf, "%s wand", dn); break; case RING_SYM: if (!obj->dknown) Sprintf(buf, "ring"); else if (nn) Sprintf(buf, "ring of %s", an); else if (un) Sprintf(buf, "ring called %s", un); else Sprintf(buf, "%s ring", dn); break; case GEM_SYM: if (!obj->dknown) { Strcpy(buf, "gem"); break; } if (!nn) { Sprintf(buf, "%s gem", dn); break; } Strcpy(buf, an); if (obj->otyp >= TURQUOISE && obj->otyp <= JADE) Strcat(buf, " stone"); break; default: Sprintf(buf, "glorkum %c (0%o) %u %d", obj->olet, obj->olet, obj->otyp, obj->spe); } if (pl) { char *p; for (p = buf; *p; p++) { if (!strncmp(" of ", p, 4)) { /* pieces of, cloves of, lumps of */ int c1, c2 = 's'; do { c1 = c2; c2 = *p; *p++ = c1; } while (c1); goto nopl; } } p = eos(buf) - 1; if (*p == 's' || *p == 'z' || *p == 'x' || (*p == 'h' && p[-1] == 's')) Strcat(buf, "es"); /* boxes */ else if (*p == 'y' && !strchr(vowels, p[-1])) Strcpy(p, "ies"); /* rubies, zruties */ else Strcat(buf, "s"); } nopl: if (obj->onamelth) { Strcat(buf, " named "); Strcat(buf, ONAME(obj)); } return (buf); } char * doname(obj) struct obj *obj; { char prefix[PREFIX]; char *bp = xname(obj); if (obj->quan != 1) Sprintf(prefix, "%u ", obj->quan); else Strcpy(prefix, "a "); switch (obj->olet) { case AMULET_SYM: if (strncmp(bp, "cheap ", 6)) Strcpy(prefix, "the "); break; case ARMOR_SYM: if (obj->owornmask & W_ARMOR) Strcat(bp, " (being worn)"); /* fall into next case */ case WEAPON_SYM: if (obj->known) { Strcat(prefix, sitoa(obj->spe)); Strcat(prefix, " "); } break; case WAND_SYM: if (obj->known) Sprintf(eos(bp), " (%d)", obj->spe); break; case RING_SYM: if (obj->owornmask & W_RINGR) Strcat(bp, " (on right hand)"); if (obj->owornmask & W_RINGL) Strcat(bp, " (on left hand)"); if (obj->known && (objects[obj->otyp].bits & SPEC)) { Strcat(prefix, sitoa(obj->spe)); Strcat(prefix, " "); } break; } if (obj->owornmask & W_WEP) Strcat(bp, " (weapon in hand)"); if (obj->unpaid) Strcat(bp, " (unpaid)"); if (!strcmp(prefix, "a ") && strchr(vowels, *bp)) Strcpy(prefix, "an "); bp = strprepend(bp, prefix); return (bp); } /* used only in hack.fight.c (thitu) */ void setan(const char *str, char *buf) { if (strchr(vowels, *str)) Sprintf(buf, "an %s", str); else Sprintf(buf, "a %s", str); } char * aobjnam(otmp, verb) struct obj *otmp; const char *verb; { char *bp = xname(otmp); char prefix[PREFIX]; if (otmp->quan != 1) { Sprintf(prefix, "%u ", otmp->quan); bp = strprepend(bp, prefix); } if (verb) { /* verb is given in plural (i.e., without trailing s) */ Strcat(bp, " "); if (otmp->quan != 1) Strcat(bp, verb); else if (!strcmp(verb, "are")) Strcat(bp, "is"); else { Strcat(bp, verb); Strcat(bp, "s"); } } return (bp); } char * Doname(obj) struct obj *obj; { char *s = doname(obj); if ('a' <= *s && *s <= 'z') *s -= ('a' - 'A'); return (s); } const char *const wrp[] = {"wand", "ring", "potion", "scroll", "gem"}; const char wrpsym[] = {WAND_SYM, RING_SYM, POTION_SYM, SCROLL_SYM, GEM_SYM}; struct obj * readobjnam(bp) char *bp; { char *p; int i; int cnt, spe, spesgn, typ, heavy; char let; char *un, *dn, *an; /* int the = 0; char *oname = 0; */ cnt = spe = spesgn = typ = heavy = 0; let = 0; an = dn = un = 0; for (p = bp; *p; p++) if ('A' <= *p && *p <= 'Z') *p += 'a' - 'A'; if (!strncmp(bp, "the ", 4)) { /* the = 1; */ bp += 4; } else if (!strncmp(bp, "an ", 3)) { cnt = 1; bp += 3; } else if (!strncmp(bp, "a ", 2)) { cnt = 1; bp += 2; } if (!cnt && digit(*bp)) { cnt = atoi(bp); while (digit(*bp)) bp++; while (*bp == ' ') bp++; } if (!cnt) cnt = 1; /* %% what with "gems" etc. ? */ if (*bp == '+' || *bp == '-') { spesgn = (*bp++ == '+') ? 1 : -1; spe = atoi(bp); while (digit(*bp)) bp++; while (*bp == ' ') bp++; } else { p = strrchr(bp, '('); if (p) { if (p > bp && p[-1] == ' ') p[-1] = 0; else *p = 0; p++; spe = atoi(p); while (digit(*p)) p++; if (strcmp(p, ")")) spe = 0; else spesgn = 1; } } /* * now we have the actual name, as delivered by xname, say green * potions called whisky scrolls labeled "QWERTY" egg dead zruties * fortune cookies very heavy iron ball named hoei wand of wishing * elven cloak */ for (p = bp; *p; p++) if (!strncmp(p, " named ", 7)) { *p = 0; /* oname = p+7; */ } for (p = bp; *p; p++) if (!strncmp(p, " called ", 8)) { *p = 0; un = p + 8; } for (p = bp; *p; p++) if (!strncmp(p, " labeled ", 9)) { *p = 0; dn = p + 9; } /* first change to singular if necessary */ if (cnt != 1) { /* find "cloves of garlic", "worthless pieces of blue glass" */ for (p = bp; *p; p++) if (!strncmp(p, "s of ", 5)) { while ((*p = p[1]) != '\0') p++; goto sing; } /* remove -s or -es (boxes) or -ies (rubies, zruties) */ p = eos(bp); if (p[-1] == 's') { if (p[-2] == 'e') { if (p[-3] == 'i') { if (!strcmp(p - 7, "cookies")) goto mins; Strcpy(p - 3, "y"); goto sing; } /* note: cloves / knives from clove / knife */ if (!strcmp(p - 6, "knives")) { Strcpy(p - 3, "fe"); goto sing; } /* note: nurses, axes but boxes */ if (!strcmp(p - 5, "boxes")) { p[-2] = 0; goto sing; } } mins: p[-1] = 0; } else { if (!strcmp(p - 9, "homunculi")) { Strcpy(p - 1, "us"); /* !! makes string * longer */ goto sing; } if (!strcmp(p - 5, "teeth")) { Strcpy(p - 5, "tooth"); goto sing; } /* here we cannot find the plural suffix */ } } sing: if (!strcmp(bp, "amulet of yendor")) { typ = AMULET_OF_YENDOR; goto typfnd; } p = eos(bp); if (!strcmp(p - 5, " mail")) { /* Note: ring mail is not a ring ! */ let = ARMOR_SYM; an = bp; goto srch; } for (i = 0; i < (int)sizeof(wrpsym); i++) { int j = strlen(wrp[i]); if (!strncmp(bp, wrp[i], j)) { let = wrpsym[i]; bp += j; if (!strncmp(bp, " of ", 4)) an = bp + 4; /* else if(*bp) ?? */ goto srch; } if (!strcmp(p - j, wrp[i])) { let = wrpsym[i]; p -= j; *p = 0; if (p[-1] == ' ') p[-1] = 0; dn = bp; goto srch; } } if (!strcmp(p - 6, " stone")) { p[-6] = 0; let = GEM_SYM; an = bp; goto srch; } if (!strcmp(bp, "very heavy iron ball")) { heavy = 1; typ = HEAVY_IRON_BALL; goto typfnd; } an = bp; srch: if (!an && !dn && !un) goto any; i = 1; if (let) i = bases[letindex(let)]; while (i <= NROFOBJECTS && (!let || objects[i].oc_olet == let)) { const char *zn = objects[i].oc_name; if (!zn) goto nxti; if (an && strcmp(an, zn)) goto nxti; if (dn && (!(zn = objects[i].oc_descr) || strcmp(dn, zn))) goto nxti; if (un && (!(zn = objects[i].oc_uname) || strcmp(un, zn))) goto nxti; typ = i; goto typfnd; nxti: i++; } any: if (!let) let = wrpsym[rn2(sizeof(wrpsym))]; typ = probtype(let); typfnd: { struct obj *otmp; let = objects[typ].oc_olet; otmp = mksobj(typ); if (heavy) otmp->owt += 15; if (cnt > 0 && strchr("%?!*)", let) && (cnt < 4 || (let == WEAPON_SYM && typ <= ROCK && cnt < 20))) otmp->quan = cnt; if (spe > 3 && spe > otmp->spe) spe = 0; else if (let == WAND_SYM) spe = otmp->spe; if (spe == 3 && u.uluck < 0) spesgn = -1; if (let != WAND_SYM && spesgn == -1) spe = -spe; if (let == BALL_SYM) spe = 0; else if (let == AMULET_SYM) spe = -1; else if (typ == WAN_WISHING && rn2(10)) spe = (rn2(10) ? -1 : 0); otmp->spe = spe; if (spesgn == -1) otmp->cursed = 1; return (otmp); } } bsd-games-2.17/hack/READ_ME0000664000175000017500000001036307077410364013737 0ustar jsm28jsm28$NetBSD: READ_ME,v 1.2 1995/03/23 08:29:12 cgd Exp $ Hack is a display oriented dungeons & dragons - like game. Both display and command structure resemble rogue. (For a game with the same structure but entirely different display - a real cave instead of dull rectangles - try Quest) Hack was originally written by Jay Fenlason (at lincolnsudbury: 29 East St., Sudbury Mass., 01776) with help from Kenny Woodland, Mike Thome and Jon Payne. Basically it was an implementation of Rogue, however, with 52+ instead of 26 monster types. The current version is more than thrice as large (with such new features as the dog, the long worms, the shops, etc.) and almost entirely rewritten (only the display routines are the original ones - I must rewrite these too one day; especially when you are blind strange things still happen). Files for hack: hack The actual game record Top 100 list (just start with an empty file) news Tells about recent changes in hack, or bugs found ... (Just start with no news file.) data Auxiliary file used by hack to give you the names and sometimes some more information on the objects and monsters. help Introductory information (no doubt outdated). hh Compactified version of help. perm An empty file used for locking purposes. rumors Texts for fortune cookies. (Some of these contain information on the game, others are just plain stupid. Additional rumors are appreciated.) hack.sh A shell script. (We have hack.sh in /usr/games/hack and hack in /usr/games/lib/hackdir/hack and all the other hack stuff in /usr/games/lib/hackdir - perhaps this will make the script clear. There is no need for you to use it.) READ_ME This file. Original_READ_ME Jay Fenlason's READ_ME System files used: /etc/termcap Used in conjunction with the environment variable $TERM. /bin/cat /usr/ucb/more /bin/sh Used when $SHELL is undefined. How to install hack: 0. Compile the sources. Perhaps you should first look at the file config.h and define BSD if you are on a BSDtype system, define STUPID if your C-compiler chokes on complicated expressions. Make sure schar and uchar represent signed and unsigned types. If your C compiler doesnt allow initialization of bit fields change Bitfield. When config.h looks reasonable, say 'make'. (Perhaps you have to change TERMLIB in the makefile.) 1. If it didnt exist already, introduce a loginname `play' . 2. The program hack resides in a directory so that it is executable for everybody and is suid play: ---s--s--x 1 play 206848 Apr 3 00:17 hack Perhaps you wish to restrict playing to certain hours, or have games running under nice; in that case you might write a program play.c such that the program play is suid play and executable for everybody while all the games in /usr/games are readable or executable for play only; all the program play does is asking for the name of a game, checking that time-of-day and system load do not forbid playing, and then executing the game. Thus: -r-sr-sr-x 1 play 13312 May 24 12:52 play ---x------ 1 play 206848 Apr 3 00:17 hack If you are worried about security you might let play do chroot("/usr/games") so that no player can get access to the rest of the system via shell escapes and the likes. If you #define SECURE in config.h then hack will not setuid(getuid()) before executing a chdir(). Hack will always do setuid(getuid()) with a fork. If you do not define UNIX then hack will not fork. 3. The rest of the stuff belonging to hack sits in a subdirectory hackdir (on our system /usr/games/lib/hackdir) with modes drwx------ 3 play 1024 Aug 9 09:03 hackdir Here all the temporary files will be created (with names like xlock.17 or user.5). 4. If you are not really short on file space, creating a subdirectory hackdir/save (modes again drwx------) will enable users to save their unfinished games. The program hack is called $ hack [-d hackdir] [maxnrofplayers] (for playing) or $ hack [-d hackdir] -s [listofusers | limit | all] (for seeing part of the scorelist). The shell file hack (in this kit called hack.sh) takes care of calling hack with the right arguments. Send complaints, bug reports, suggestions for improvements to mcvax!aeb - in real life Andries Brouwer. bsd-games-2.17/hack/hack.bones.c0000664000175000017500000001314307767741711015107 0ustar jsm28jsm28/* $NetBSD: hack.bones.c,v 1.6 2003/04/02 18:36:35 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.bones.c,v 1.6 2003/04/02 18:36:35 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #include #include char bones[] = "bones_xx"; /* save bones and possessions of a deceased adventurer */ void savebones() { int fd; struct obj *otmp; struct trap *ttmp; struct monst *mtmp; if (dlevel <= 0 || dlevel > MAXLEVEL) return; if (!rn2(1 + dlevel / 2)) return; /* not so many ghosts on low levels */ bones[6] = '0' + (dlevel / 10); bones[7] = '0' + (dlevel % 10); if ((fd = open(bones, O_RDONLY)) >= 0) { (void) close(fd); return; } /* drop everything; the corpse's possessions are usually cursed */ otmp = invent; while (otmp) { otmp->ox = u.ux; otmp->oy = u.uy; otmp->age = 0; /* very long ago */ otmp->owornmask = 0; if (rn2(5)) otmp->cursed = 1; if (!otmp->nobj) { otmp->nobj = fobj; fobj = invent; invent = 0; /* superfluous */ break; } otmp = otmp->nobj; } if (!(mtmp = makemon(PM_GHOST, u.ux, u.uy))) return; mtmp->mx = u.ux; mtmp->my = u.uy; mtmp->msleep = 1; (void) strcpy((char *) mtmp->mextra, plname); mkgold(somegold() + d(dlevel, 30), u.ux, u.uy); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { mtmp->m_id = 0; if (mtmp->mtame) { mtmp->mtame = 0; mtmp->mpeaceful = 0; } mtmp->mlstmv = 0; if (mtmp->mdispl) unpmon(mtmp); } for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) ttmp->tseen = 0; for (otmp = fobj; otmp; otmp = otmp->nobj) { otmp->o_id = 0; /* otmp->o_cnt_id = 0; - superfluous */ otmp->onamelth = 0; otmp->known = 0; otmp->invlet = 0; if (otmp->olet == AMULET_SYM && !otmp->spe) { otmp->spe = -1; /* no longer the actual amulet */ otmp->cursed = 1; /* flag as gotten from a * ghost */ } } if ((fd = creat(bones, FMASK)) < 0) return; savelev(fd, dlevel); (void) close(fd); } int getbones() { int fd, x, y, ok; if (rn2(3)) return (0); /* only once in three times do we find bones */ bones[6] = '0' + dlevel / 10; bones[7] = '0' + dlevel % 10; if ((fd = open(bones, O_RDONLY)) < 0) return (0); if ((ok = uptodate(fd)) != 0) { getlev(fd, 0, dlevel); for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) levl[x][y].seen = levl[x][y].new = 0; } (void) close(fd); #ifdef WIZARD if (!wizard) /* duvel!frans: don't remove bones while * debugging */ #endif /* WiZARD */ if (unlink(bones) < 0) { pline("Cannot unlink %s .", bones); return (0); } return (ok); } bsd-games-2.17/hack/hack.potion.c0000664000175000017500000002751207767741711015316 0ustar jsm28jsm28/* $NetBSD: hack.potion.c,v 1.6 2003/04/02 18:36:39 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.potion.c,v 1.6 2003/04/02 18:36:39 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" int dodrink() { struct obj *otmp, *objs; struct monst *mtmp; int unkn = 0, nothing = 0; otmp = getobj("!", "drink"); if (!otmp) return (0); if (!strcmp(objects[otmp->otyp].oc_descr, "smoky") && !rn2(13)) { ghost_from_bottle(); goto use_it; } switch (otmp->otyp) { case POT_RESTORE_STRENGTH: unkn++; pline("Wow! This makes you feel great!"); if (u.ustr < u.ustrmax) { u.ustr = u.ustrmax; flags.botl = 1; } break; case POT_BOOZE: unkn++; pline("Ooph! This tastes like liquid fire!"); Confusion += d(3, 8); /* the whiskey makes us feel better */ if (u.uhp < u.uhpmax) losehp(-1, "bottle of whiskey"); if (!rn2(4)) { pline("You pass out."); multi = -rnd(15); nomovemsg = "You awake with a headache."; } break; case POT_INVISIBILITY: if (Invis || See_invisible) nothing++; else { if (!Blind) pline("Gee! All of a sudden, you can't see yourself."); else pline("You feel rather airy."), unkn++; newsym(u.ux, u.uy); } Invis += rn1(15, 31); break; case POT_FRUIT_JUICE: pline("This tastes like fruit juice."); lesshungry(20); break; case POT_HEALING: pline("You begin to feel better."); flags.botl = 1; u.uhp += rnd(10); if (u.uhp > u.uhpmax) u.uhp = ++u.uhpmax; if (Blind) Blind = 1; /* see on next move */ if (Sick) Sick = 0; break; case POT_PARALYSIS: if (Levitation) pline("You are motionlessly suspended."); else pline("Your feet are frozen to the floor!"); nomul(-(rn1(10, 25))); break; case POT_MONSTER_DETECTION: if (!fmon) { strange_feeling(otmp, "You feel threatened."); return (1); } else { cls(); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp->mx > 0) at(mtmp->mx, mtmp->my, mtmp->data->mlet); prme(); pline("You sense the presence of monsters."); more(); docrt(); } break; case POT_OBJECT_DETECTION: if (!fobj) { strange_feeling(otmp, "You feel a pull downward."); return (1); } else { for (objs = fobj; objs; objs = objs->nobj) if (objs->ox != u.ux || objs->oy != u.uy) goto outobjmap; pline("You sense the presence of objects close nearby."); break; outobjmap: cls(); for (objs = fobj; objs; objs = objs->nobj) at(objs->ox, objs->oy, objs->olet); prme(); pline("You sense the presence of objects."); more(); docrt(); } break; case POT_SICKNESS: pline("Yech! This stuff tastes like poison."); if (Poison_resistance) pline("(But in fact it was biologically contaminated orange juice.)"); losestr(rn1(4, 3)); losehp(rnd(10), "contaminated potion"); break; case POT_CONFUSION: if (!Confusion) pline("Huh, What? Where am I?"); else nothing++; Confusion += rn1(7, 16); break; case POT_GAIN_STRENGTH: pline("Wow do you feel strong!"); if (u.ustr >= 118) break; /* > 118 is impossible */ if (u.ustr > 17) u.ustr += rnd(118 - u.ustr); else u.ustr++; if (u.ustr > u.ustrmax) u.ustrmax = u.ustr; flags.botl = 1; break; case POT_SPEED: if (Wounded_legs) { heal_legs(); unkn++; break; } if (!(Fast & ~INTRINSIC)) pline("You are suddenly moving much faster."); else pline("Your legs get new energy."), unkn++; Fast += rn1(10, 100); break; case POT_BLINDNESS: if (!Blind) pline("A cloud of darkness falls upon you."); else nothing++; Blind += rn1(100, 250); seeoff(0); break; case POT_GAIN_LEVEL: pluslvl(); break; case POT_EXTRA_HEALING: pline("You feel much better."); flags.botl = 1; u.uhp += d(2, 20) + 1; if (u.uhp > u.uhpmax) u.uhp = (u.uhpmax += 2); if (Blind) Blind = 1; if (Sick) Sick = 0; break; case POT_LEVITATION: if (!Levitation) float_up(); else nothing++; Levitation += rnd(100); u.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down; break; default: impossible("What a funny potion! (%u)", otmp->otyp); return (0); } if (nothing) { unkn++; pline("You have a peculiar feeling for a moment, then it passes."); } if (otmp->dknown && !objects[otmp->otyp].oc_name_known) { if (!unkn) { objects[otmp->otyp].oc_name_known = 1; more_experienced(0, 10); } else if (!objects[otmp->otyp].oc_uname) docall(otmp); } use_it: useup(otmp); return (1); } void pluslvl() { int num; pline("You feel more experienced."); num = rnd(10); u.uhpmax += num; u.uhp += num; if (u.ulevel < 14) { u.uexp = newuexp() + 1; pline("Welcome to experience level %u.", ++u.ulevel); } flags.botl = 1; } void strange_feeling(obj, txt) struct obj *obj; const char *txt; { if (flags.beginner) pline("You have a strange feeling for a moment, then it passes."); else pline(txt); if (!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname) docall(obj); useup(obj); } const char *const bottlenames[] = { "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial" }; void potionhit(mon, obj) struct monst *mon; struct obj *obj; { const char *botlnam = bottlenames[rn2(SIZE(bottlenames))]; boolean uclose, isyou = (mon == &youmonst); if (isyou) { uclose = TRUE; pline("The %s crashes on your head and breaks into shivers.", botlnam); losehp(rnd(2), "thrown potion"); } else { uclose = (dist(mon->mx, mon->my) < 3); /* perhaps 'E' and 'a' have no head? */ pline("The %s crashes on %s's head and breaks into shivers.", botlnam, monnam(mon)); if (rn2(5) && mon->mhp > 1) mon->mhp--; } pline("The %s evaporates.", xname(obj)); if (!isyou && !rn2(3)) switch (obj->otyp) { case POT_RESTORE_STRENGTH: case POT_GAIN_STRENGTH: case POT_HEALING: case POT_EXTRA_HEALING: if (mon->mhp < mon->mhpmax) { mon->mhp = mon->mhpmax; pline("%s looks sound and hale again!", Monnam(mon)); } break; case POT_SICKNESS: if (mon->mhpmax > 3) mon->mhpmax /= 2; if (mon->mhp > 2) mon->mhp /= 2; break; case POT_CONFUSION: case POT_BOOZE: mon->mconf = 1; break; case POT_INVISIBILITY: unpmon(mon); mon->minvis = 1; pmon(mon); break; case POT_PARALYSIS: mon->mfroz = 1; break; case POT_SPEED: mon->mspeed = MFAST; break; case POT_BLINDNESS: mon->mblinded |= 64 + rn2(64); break; /* * case POT_GAIN_LEVEL: case POT_LEVITATION: case * POT_FRUIT_JUICE: case POT_MONSTER_DETECTION: case * POT_OBJECT_DETECTION: break; */ } if (uclose && rn2(5)) potionbreathe(obj); obfree(obj, Null(obj)); } void potionbreathe(obj) struct obj *obj; { switch (obj->otyp) { case POT_RESTORE_STRENGTH: case POT_GAIN_STRENGTH: if (u.ustr < u.ustrmax) u.ustr++, flags.botl = 1; break; case POT_HEALING: case POT_EXTRA_HEALING: if (u.uhp < u.uhpmax) u.uhp++, flags.botl = 1; break; case POT_SICKNESS: if (u.uhp <= 5) u.uhp = 1; else u.uhp -= 5; flags.botl = 1; break; case POT_CONFUSION: case POT_BOOZE: if (!Confusion) pline("You feel somewhat dizzy."); Confusion += rnd(5); break; case POT_INVISIBILITY: pline("For an instant you couldn't see your right hand."); break; case POT_PARALYSIS: pline("Something seems to be holding you."); nomul(-rnd(5)); break; case POT_SPEED: Fast += rnd(5); pline("Your knees seem more flexible now."); break; case POT_BLINDNESS: if (!Blind) pline("It suddenly gets dark."); Blind += rnd(5); seeoff(0); break; /* * case POT_GAIN_LEVEL: case POT_LEVITATION: case * POT_FRUIT_JUICE: case POT_MONSTER_DETECTION: case * POT_OBJECT_DETECTION: break; */ } /* note: no obfree() */ } /* * -- rudimentary -- to do this correctly requires much more work * -- all sharp weapons get one or more qualities derived from the potions * -- texts on scrolls may be (partially) wiped out; do they become blank? * -- or does their effect change, like under Confusion? * -- all objects may be made invisible by POT_INVISIBILITY * -- If the flask is small, can one dip a large object? Does it magically * -- become a jug? Etc. */ int dodip() { struct obj *potion, *obj; if (!(obj = getobj("#", "dip"))) return (0); if (!(potion = getobj("!", "dip into"))) return (0); pline("Interesting..."); if (obj->otyp == ARROW || obj->otyp == DART || obj->otyp == CROSSBOW_BOLT) { if (potion->otyp == POT_SICKNESS) { useup(potion); if (obj->spe < 7) obj->spe++; /* %% */ } } return (1); } void ghost_from_bottle() { struct monst *mtmp; if (!(mtmp = makemon(PM_GHOST, u.ux, u.uy))) { pline("This bottle turns out to be empty."); return; } mnexto(mtmp); pline("As you open the bottle, an enormous ghost emerges!"); pline("You are frightened to death, and unable to move."); nomul(-3); } bsd-games-2.17/hack/makedefs.c0000664000175000017500000002056007767741711014654 0ustar jsm28jsm28/* $NetBSD: makedefs.c,v 1.8 2003/04/02 18:36:42 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef lint static const char rcsid[] __attribute__((__unused__)) = "$NetBSD: makedefs.c,v 1.8 2003/04/02 18:36:42 jsm Exp $"; #endif /* not lint */ #include #include #include #include #include /* construct definitions of object constants */ #define LINSZ 1000 #define STRSZ 40 int fd; char string[STRSZ]; static void readline(void); static char nextchar(void); static int skipuntil(const char *); static int getentry(void); static void capitalize(char *); static int letter(int); static int digit(int); int main(int, char **); int main(argc, argv) int argc; char **argv; { int i = 0; int propct = 0; char *sp; if (argc != 2) { (void) fprintf(stderr, "usage: makedefs file\n"); exit(1); } if ((fd = open(argv[1], O_RDONLY)) < 0) { perror(argv[1]); exit(1); } skipuntil("objects[] = {"); while (getentry()) { if (!*string) { i++; continue; } for (sp = string; *sp; sp++) if (*sp == ' ' || *sp == '\t' || *sp == '-') *sp = '_'; if (!strncmp(string, "RIN_", 4)) { capitalize(string + 4); printf("#define %s u.uprops[%d].p_flgs\n", string + 4, propct++); } for (sp = string; *sp; sp++) capitalize(sp); /* avoid trouble with stupid C preprocessors */ if (!strncmp(string, "WORTHLESS_PIECE_OF_", 19)) printf("/* #define %s %d */\n", string, i); else printf("#define %s %d\n", string, i); i++; } printf("\n#define CORPSE DEAD_HUMAN\n"); printf("#define LAST_GEM (JADE+1)\n"); printf("#define LAST_RING %d\n", propct); printf("#define NROFOBJECTS %d\n", i - 1); fflush(stdout); if (ferror(stdout)) { perror("standard output"); exit(1); } exit(0); } char line[LINSZ], *lp = line, *lp0 = line, *lpe = line; int eof; static void readline() { int n = read(fd, lp0, (line + LINSZ) - lp0); if (n < 0) { printf("Input error.\n"); exit(1); } if (n == 0) eof++; lpe = lp0 + n; } static char nextchar() { if (lp == lpe) { readline(); lp = lp0; } return ((lp == lpe) ? 0 : *lp++); } static int skipuntil(s) const char *s; { const char *sp0; char *sp1; loop: while (*s != nextchar()) if (eof) { printf("Cannot skipuntil %s\n", s); exit(1); } if ((int)strlen(s) > lpe - lp + 1) { char *lp1, *lp2; lp2 = lp; lp1 = lp = lp0; while (lp2 != lpe) *lp1++ = *lp2++; lp2 = lp0; /* save value */ lp0 = lp1; readline(); lp0 = lp2; if ((int)strlen(s) > lpe - lp + 1) { printf("error in skipuntil"); exit(1); } } sp0 = s + 1; sp1 = lp; while (*sp0 && *sp0 == *sp1) sp0++, sp1++; if (!*sp0) { lp = sp1; return (1); } goto loop; } static int getentry() { int inbraces = 0, inparens = 0, stringseen = 0, commaseen = 0; int prefix = 0; char ch; #define NSZ 10 char identif[NSZ], *ip; string[0] = string[4] = 0; /* * read until {...} or XXX(...) followed by , skip comment and * #define lines deliver 0 on failure */ while (1) { ch = nextchar(); swi: if (letter(ch)) { ip = identif; do { if (ip < identif + NSZ - 1) *ip++ = ch; ch = nextchar(); } while (letter(ch) || digit(ch)); *ip = 0; while (ch == ' ' || ch == '\t') ch = nextchar(); if (ch == '(' && !inparens && !stringseen) if (!strcmp(identif, "WAND") || !strcmp(identif, "RING") || !strcmp(identif, "POTION") || !strcmp(identif, "SCROLL")) (void) strncpy(string, identif, 3), string[3] = '_', prefix = 4; } switch (ch) { case '/': /* watch for comment */ if ((ch = nextchar()) == '*') skipuntil("*/"); goto swi; case '{': inbraces++; continue; case '(': inparens++; continue; case '}': inbraces--; if (inbraces < 0) return (0); continue; case ')': inparens--; if (inparens < 0) { printf("too many ) ?"); exit(1); } continue; case '\n': /* watch for #define at begin of line */ if ((ch = nextchar()) == '#') { char pch; /* skip until '\n' not preceded by '\\' */ do { pch = ch; ch = nextchar(); } while (ch != '\n' || pch == '\\'); continue; } goto swi; case ',': if (!inparens && !inbraces) { if (prefix && !string[prefix]) string[0] = 0; if (stringseen) return (1); printf("unexpected ,\n"); exit(1); } commaseen++; continue; case '\'': if ((ch = nextchar()) == '\\') ch = nextchar(); if (nextchar() != '\'') { printf("strange character denotation?\n"); exit(1); } continue; case '"': { char *sp = string + prefix; char pch; int store = (inbraces || inparens) && !stringseen++ && !commaseen; do { pch = ch; ch = nextchar(); if (store && sp < string + STRSZ) *sp++ = ch; } while (ch != '"' || pch == '\\'); if (store) *--sp = 0; continue; } } } } static void capitalize(sp) char *sp; { if ('a' <= *sp && *sp <= 'z') *sp += 'A' - 'a'; } static int letter(ch) char ch; { return (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')); } static int digit(ch) char ch; { return ('0' <= ch && ch <= '9'); } bsd-games-2.17/hack/hack.read.c0000664000175000017500000004037507767741711014723 0ustar jsm28jsm28/* $NetBSD: hack.read.c,v 1.8 2003/04/02 18:36:39 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.read.c,v 1.8 2003/04/02 18:36:39 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" int doread() { struct obj *scroll; boolean confused = (Confusion != 0); boolean known = FALSE; scroll = getobj("?", "read"); if (!scroll) return (0); if (!scroll->dknown && Blind) { pline("Being blind, you cannot read the formula on the scroll."); return (0); } if (Blind) pline("As you pronounce the formula on it, the scroll disappears."); else pline("As you read the scroll, it disappears."); if (confused) pline("Being confused, you mispronounce the magic words ... "); switch (scroll->otyp) { #ifdef MAIL case SCR_MAIL: readmail( /* scroll */ ); break; #endif /* MAIL */ case SCR_ENCHANT_ARMOR: { struct obj *otmp = some_armor(); if (!otmp) { strange_feeling(scroll, "Your skin glows then fades."); return (1); } if (confused) { pline("Your %s glows silver for a moment.", objects[otmp->otyp].oc_name); otmp->rustfree = 1; break; } if (otmp->spe > 3 && rn2(otmp->spe)) { pline("Your %s glows violently green for a while, then evaporates.", objects[otmp->otyp].oc_name); useup(otmp); break; } pline("Your %s glows green for a moment.", objects[otmp->otyp].oc_name); otmp->cursed = 0; otmp->spe++; break; } case SCR_DESTROY_ARMOR: if (confused) { struct obj *otmp = some_armor(); if (!otmp) { strange_feeling(scroll, "Your bones itch."); return (1); } pline("Your %s glows purple for a moment.", objects[otmp->otyp].oc_name); otmp->rustfree = 0; break; } if (uarm) { pline("Your armor turns to dust and falls to the floor!"); useup(uarm); } else if (uarmh) { pline("Your helmet turns to dust and is blown away!"); useup(uarmh); } else if (uarmg) { pline("Your gloves vanish!"); useup(uarmg); selftouch("You"); } else { strange_feeling(scroll, "Your skin itches."); return (1); } break; case SCR_CONFUSE_MONSTER: if (confused) { pline("Your hands begin to glow purple."); Confusion += rnd(100); } else { pline("Your hands begin to glow blue."); u.umconf = 1; } break; case SCR_SCARE_MONSTER: { int ct = 0; struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (cansee(mtmp->mx, mtmp->my)) { if (confused) mtmp->mflee = mtmp->mfroz = mtmp->msleep = 0; else mtmp->mflee = 1; ct++; } if (!ct) { if (confused) pline("You hear sad wailing in the distance."); else pline("You hear maniacal laughter in the distance."); } break; } case SCR_BLANK_PAPER: if (confused) pline("You see strange patterns on this scroll."); else pline("This scroll seems to be blank."); break; case SCR_REMOVE_CURSE: { struct obj *obj; if (confused) pline("You feel like you need some help."); else pline("You feel like someone is helping you."); for (obj = invent; obj; obj = obj->nobj) if (obj->owornmask) obj->cursed = confused; if (Punished && !confused) { Punished = 0; freeobj(uchain); unpobj(uchain); free((char *) uchain); uball->spe = 0; uball->owornmask &= ~W_BALL; uchain = uball = (struct obj *) 0; } break; } case SCR_CREATE_MONSTER: { int cnt = 1; if (!rn2(73)) cnt += rnd(4); if (confused) cnt += 12; while (cnt--) (void) makemon(confused ? PM_ACID_BLOB : (struct permonst *) 0, u.ux, u.uy); break; } case SCR_ENCHANT_WEAPON: if (uwep && confused) { pline("Your %s glows silver for a moment.", objects[uwep->otyp].oc_name); uwep->rustfree = 1; } else if (!chwepon(scroll, 1)) /* tests for !uwep */ return (1); break; case SCR_DAMAGE_WEAPON: if (uwep && confused) { pline("Your %s glows purple for a moment.", objects[uwep->otyp].oc_name); uwep->rustfree = 0; } else if (!chwepon(scroll, -1)) /* tests for !uwep */ return (1); break; case SCR_TAMING: { int i, j; int bd = confused ? 5 : 1; struct monst *mtmp; for (i = -bd; i <= bd; i++) for (j = -bd; j <= bd; j++) if ((mtmp = m_at(u.ux + i, u.uy + j)) != NULL) (void) tamedog(mtmp, (struct obj *) 0); break; } case SCR_GENOCIDE: { char buf[BUFSZ]; struct monst *mtmp, *mtmp2; pline("You have found a scroll of genocide!"); known = TRUE; if (confused) *buf = u.usym; else do { pline("What monster do you want to genocide (Type the letter)? "); getlin(buf); } while (strlen(buf) != 1 || !monstersym(*buf)); if (!strchr(fut_geno, *buf)) charcat(fut_geno, *buf); if (!strchr(genocided, *buf)) charcat(genocided, *buf); else { pline("Such monsters do not exist in this world."); break; } for (mtmp = fmon; mtmp; mtmp = mtmp2) { mtmp2 = mtmp->nmon; if (mtmp->data->mlet == *buf) mondead(mtmp); } pline("Wiped out all %c's.", *buf); if (*buf == u.usym) { killer = "scroll of genocide"; u.uhp = -1; } break; } case SCR_LIGHT: if (!Blind) known = TRUE; litroom(!confused); break; case SCR_TELEPORTATION: if (confused) level_tele(); else { #ifdef QUEST int oux = u.ux, ouy = u.uy; tele(); if (dist(oux, ouy) > 100) known = TRUE; #else /* QUEST */ int uroom = inroom(u.ux, u.uy); tele(); if (uroom != inroom(u.ux, u.uy)) known = TRUE; #endif /* QUEST */ } break; case SCR_GOLD_DETECTION: /* * Unfortunately this code has become slightly less elegant, * now that gold and traps no longer are of the same type. */ if (confused) { struct trap *ttmp; if (!ftrap) { strange_feeling(scroll, "Your toes stop itching."); return (1); } else { for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) if (ttmp->tx != u.ux || ttmp->ty != u.uy) goto outtrapmap; /* * only under me - no separate display * required */ pline("Your toes itch!"); break; outtrapmap: cls(); for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) at(ttmp->tx, ttmp->ty, '$'); prme(); pline("You feel very greedy!"); } } else { struct gold *gtmp; if (!fgold) { strange_feeling(scroll, "You feel materially poor."); return (1); } else { known = TRUE; for (gtmp = fgold; gtmp; gtmp = gtmp->ngold) if (gtmp->gx != u.ux || gtmp->gy != u.uy) goto outgoldmap; /* * only under me - no separate display * required */ pline("You notice some gold between your feet."); break; outgoldmap: cls(); for (gtmp = fgold; gtmp; gtmp = gtmp->ngold) at(gtmp->gx, gtmp->gy, '$'); prme(); pline("You feel very greedy, and sense gold!"); } } /* common sequel */ more(); docrt(); break; case SCR_FOOD_DETECTION: { int ct = 0, ctu = 0; struct obj *obj; char foodsym = confused ? POTION_SYM : FOOD_SYM; for (obj = fobj; obj; obj = obj->nobj) if (obj->olet == FOOD_SYM) { if (obj->ox == u.ux && obj->oy == u.uy) ctu++; else ct++; } if (!ct && !ctu) { strange_feeling(scroll, "Your nose twitches."); return (1); } else if (!ct) { known = TRUE; pline("You smell %s close nearby.", confused ? "something" : "food"); } else { known = TRUE; cls(); for (obj = fobj; obj; obj = obj->nobj) if (obj->olet == foodsym) at(obj->ox, obj->oy, FOOD_SYM); prme(); pline("Your nose tingles and you smell %s!", confused ? "something" : "food"); more(); docrt(); } break; } case SCR_IDENTIFY: /* known = TRUE; */ if (confused) pline("You identify this as an identify scroll."); else pline("This is an identify scroll."); useup(scroll); objects[SCR_IDENTIFY].oc_name_known = 1; if (!confused) while ( !ggetobj("identify", identify, rn2(5) ? 1 : rn2(5)) && invent ); return (1); case SCR_MAGIC_MAPPING: { struct rm *lev; int num, zx, zy; known = TRUE; pline("On this scroll %s a map!", confused ? "was" : "is"); for (zy = 0; zy < ROWNO; zy++) for (zx = 0; zx < COLNO; zx++) { if (confused && rn2(7)) continue; lev = &(levl[zx][zy]); if ((num = lev->typ) == 0) continue; if (num == SCORR) { lev->typ = CORR; lev->scrsym = CORR_SYM; } else if (num == SDOOR) { lev->typ = DOOR; lev->scrsym = '+'; /* do sth in doors ? */ } else if (lev->seen) continue; #ifndef QUEST if (num != ROOM) #endif /* QUEST */ { lev->seen = lev->new = 1; if (lev->scrsym == ' ' || !lev->scrsym) newsym(zx, zy); else on_scr(zx, zy); } } break; } case SCR_AMNESIA: { int zx, zy; known = TRUE; for (zx = 0; zx < COLNO; zx++) for (zy = 0; zy < ROWNO; zy++) if (!confused || rn2(7)) if (!cansee(zx, zy)) levl[zx][zy].seen = 0; docrt(); pline("Thinking of Maud you forget everything else."); break; } case SCR_FIRE: { int num = 0; struct monst *mtmp; known = TRUE; if (confused) { pline("The scroll catches fire and you burn your hands."); losehp(1, "scroll of fire"); } else { pline("The scroll erupts in a tower of flame!"); if (Fire_resistance) pline("You are uninjured."); else { num = rnd(6); u.uhpmax -= num; losehp(num, "scroll of fire"); } } num = (2 * num + 1) / 3; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (dist(mtmp->mx, mtmp->my) < 3) { mtmp->mhp -= num; if (strchr("FY", mtmp->data->mlet)) mtmp->mhp -= 3 * num; /* this might well kill * 'F's */ if (mtmp->mhp < 1) { killed(mtmp); break; /* primitive */ } } } break; } case SCR_PUNISHMENT: known = TRUE; if (confused) { pline("You feel guilty."); break; } pline("You are being punished for your misbehaviour!"); if (Punished) { pline("Your iron ball gets heavier."); uball->owt += 15; break; } Punished = INTRINSIC; setworn(mkobj_at(CHAIN_SYM, u.ux, u.uy), W_CHAIN); setworn(mkobj_at(BALL_SYM, u.ux, u.uy), W_BALL); uball->spe = 1; /* special ball (see save) */ break; default: impossible("What weird language is this written in? (%u)", scroll->otyp); } if (!objects[scroll->otyp].oc_name_known) { if (known && !confused) { objects[scroll->otyp].oc_name_known = 1; more_experienced(0, 10); } else if (!objects[scroll->otyp].oc_uname) docall(scroll); } useup(scroll); return (1); } int identify(otmp) /* also called by newmail() */ struct obj *otmp; { objects[otmp->otyp].oc_name_known = 1; otmp->known = otmp->dknown = 1; prinv(otmp); return (1); } void litroom(on) boolean on; { #ifndef QUEST int num, zx, zy; #endif /* first produce the text (provided he is not blind) */ if (Blind) goto do_it; if (!on) { if (u.uswallow || !xdnstair || levl[u.ux][u.uy].typ == CORR || !levl[u.ux][u.uy].lit) { pline("It seems even darker in here than before."); return; } else pline("It suddenly becomes dark in here."); } else { if (u.uswallow) { pline("%s's stomach is lit.", Monnam(u.ustuck)); return; } if (!xdnstair) { pline("Nothing Happens."); return; } #ifdef QUEST pline("The cave lights up around you, then fades."); return; #else /* QUEST */ if (levl[u.ux][u.uy].typ == CORR) { pline("The corridor lights up around you, then fades."); return; } else if (levl[u.ux][u.uy].lit) { pline("The light here seems better now."); return; } else pline("The room is lit."); #endif /* QUEST */ } do_it: #ifdef QUEST return; #else /* QUEST */ if (levl[u.ux][u.uy].lit == on) return; if (levl[u.ux][u.uy].typ == DOOR) { if (IS_ROOM(levl[u.ux][u.uy + 1].typ)) zy = u.uy + 1; else if (IS_ROOM(levl[u.ux][u.uy - 1].typ)) zy = u.uy - 1; else zy = u.uy; if (IS_ROOM(levl[u.ux + 1][u.uy].typ)) zx = u.ux + 1; else if (IS_ROOM(levl[u.ux - 1][u.uy].typ)) zx = u.ux - 1; else zx = u.ux; } else { zx = u.ux; zy = u.uy; } for (seelx = u.ux; (num = levl[seelx - 1][zy].typ) != CORR && num != 0; seelx--); for (seehx = u.ux; (num = levl[seehx + 1][zy].typ) != CORR && num != 0; seehx++); for (seely = u.uy; (num = levl[zx][seely - 1].typ) != CORR && num != 0; seely--); for (seehy = u.uy; (num = levl[zx][seehy + 1].typ) != CORR && num != 0; seehy++); for (zy = seely; zy <= seehy; zy++) for (zx = seelx; zx <= seehx; zx++) { levl[zx][zy].lit = on; if (!Blind && dist(zx, zy) > 2) { if (on) prl(zx, zy); else nosee(zx, zy); } } if (!on) seehx = 0; #endif /* QUEST */ } /* Test whether we may genocide all monsters with symbol ch */ int monstersym(ch) /* arnold@ucsfcgl */ char ch; { const struct permonst *mp; /* * can't genocide certain monsters */ if (strchr("12 &:", ch)) return FALSE; if (ch == pm_eel.mlet) return TRUE; for (mp = mons; mp < &mons[CMNUM + 2]; mp++) if (mp->mlet == ch) return TRUE; return FALSE; } bsd-games-2.17/hack/def.edog.h0000664000175000017500000000702707767741711014560 0ustar jsm28jsm28/* $NetBSD: def.edog.h,v 1.5 2003/04/02 18:36:33 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_EDOG_H_ #define _DEF_EDOG_H_ struct edog { long hungrytime; /* at this time dog gets hungry */ long eattime; /* dog is eating */ long droptime; /* moment dog dropped object */ unsigned dropdist; /* dist of drpped obj from @ */ unsigned apport; /* amount of training */ long whistletime; /* last time he whistled */ }; #define EDOG(mp) ((struct edog *)(&(mp->mextra[0]))) #endif /* _DEF_EDOG_H_ */ bsd-games-2.17/hack/def.rm.h0000664000175000017500000001046507767741711014260 0ustar jsm28jsm28/* $NetBSD: def.rm.h,v 1.6 2003/04/02 18:36:35 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_RM_H_ #define _DEF_RM_H_ /* Level location types */ #define HWALL 1 #define VWALL 2 #define SDOOR 3 #define SCORR 4 #define LDOOR 5 #define POOL 6 /* not yet fully implemented */ /* this should in fact be a bit like lit */ #define DOOR 7 #define CORR 8 #define ROOM 9 #define STAIRS 10 /* * Avoid using the level types in inequalities: * these types are subject to change. * Instead, use one of the macros below. */ #define IS_WALL(typ) ((typ) <= VWALL) #define IS_ROCK(typ) ((typ) < POOL) /* absolutely nonaccessible */ #define ACCESSIBLE(typ) ((typ) >= DOOR) /* good position */ #define IS_ROOM(typ) ((typ) >= ROOM) /* ROOM or STAIRS */ #define ZAP_POS(typ) ((typ) > DOOR) /* * A few of the associated symbols are not hardwired. */ #ifdef QUEST #define CORR_SYM ':' #else #define CORR_SYM '#' #endif /* QUEST */ #define POOL_SYM '}' #define ERRCHAR '{' /* * The structure describing a coordinate position. * Before adding fields, remember that this will significantly affect * the size of temporary files and save files. */ struct rm { char scrsym; unsigned typ:5; unsigned new:1; unsigned seen:1; unsigned lit:1; }; extern struct rm levl[COLNO][ROWNO]; #endif /* _DEF_RM_H_ */ bsd-games-2.17/hack/hack.mklev.c0000664000175000017500000005015307767741711015121 0ustar jsm28jsm28/* $NetBSD: hack.mklev.c,v 1.6 2003/04/02 18:36:38 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.mklev.c,v 1.6 2003/04/02 18:36:38 jsm Exp $"); #endif /* not lint */ #include #include #include "hack.h" #include "extern.h" #define somex() ((random()%(croom->hx-croom->lx+1))+croom->lx) #define somey() ((random()%(croom->hy-croom->ly+1))+croom->ly) #include "def.mkroom.h" #define XLIM 4 /* define minimum required space around a * room */ #define YLIM 3 boolean secret; /* TRUE while making a vault: increase * [XY]LIM */ int smeq[MAXNROFROOMS + 1]; int doorindex; struct rm zerorm; schar nxcor; boolean goldseen; int nroom; /* Definitions used by makerooms() and addrs() */ #define MAXRS 50 /* max lth of temp rectangle table - * arbitrary */ struct rectangle { xchar rlx, rly, rhx, rhy; } rs[MAXRS + 1]; int rscnt, rsmax; /* 0..rscnt-1: currently under consideration */ /* rscnt..rsmax: discarded */ void makelevel() { struct mkroom *croom, *troom; unsigned tryct; int x, y; nroom = 0; doorindex = 0; rooms[0].hx = -1; /* in case we are in a maze */ for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) levl[x][y] = zerorm; oinit(); /* assign level dependent obj probabilities */ if (dlevel >= rn1(3, 26)) { /* there might be several mazes */ makemaz(); return; } /* construct the rooms */ nroom = 0; secret = FALSE; (void) makerooms(); /* construct stairs (up and down in different rooms if possible) */ croom = &rooms[rn2(nroom)]; xdnstair = somex(); ydnstair = somey(); levl[xdnstair][ydnstair].scrsym = '>'; levl[xdnstair][ydnstair].typ = STAIRS; if (nroom > 1) { troom = croom; croom = &rooms[rn2(nroom - 1)]; if (croom >= troom) croom++; } xupstair = somex(); /* %% < and > might be in the same place */ yupstair = somey(); levl[xupstair][yupstair].scrsym = '<'; levl[xupstair][yupstair].typ = STAIRS; /* for each room: put things inside */ for (croom = rooms; croom->hx > 0; croom++) { /* put a sleeping monster inside */ /* * Note: monster may be on the stairs. This cannot be * avoided: maybe the player fell through a trapdoor while a * monster was on the stairs. Conclusion: we have to check * for monsters on the stairs anyway. */ if (!rn2(3)) (void) makemon((struct permonst *) 0, somex(), somey()); /* put traps and mimics inside */ goldseen = FALSE; while (!rn2(8 - (dlevel / 6))) mktrap(0, 0, croom); if (!goldseen && !rn2(3)) mkgold(0L, somex(), somey()); if (!rn2(3)) { (void) mkobj_at(0, somex(), somey()); tryct = 0; while (!rn2(5)) { if (++tryct > 100) { printf("tryct overflow4\n"); break; } (void) mkobj_at(0, somex(), somey()); } } } qsort((char *) rooms, nroom, sizeof(struct mkroom), comp); makecorridors(); make_niches(); /* make a secret treasure vault, not connected to the rest */ if (nroom <= (2 * MAXNROFROOMS / 3)) if (rn2(3)) { troom = &rooms[nroom]; secret = TRUE; if (makerooms()) { troom->rtype = VAULT; /* treasure vault */ for (x = troom->lx; x <= troom->hx; x++) for (y = troom->ly; y <= troom->hy; y++) mkgold((long) (rnd(dlevel * 100) + 50), x, y); if (!rn2(3)) makevtele(); } } #ifndef QUEST #ifdef WIZARD if (wizard && getenv("SHOPTYPE")) mkshop(); else #endif /* WIZARD */ if (dlevel > 1 && dlevel < 20 && rn2(dlevel) < 3) mkshop(); else if (dlevel > 6 && !rn2(7)) mkzoo(ZOO); else if (dlevel > 9 && !rn2(5)) mkzoo(BEEHIVE); else if (dlevel > 11 && !rn2(6)) mkzoo(MORGUE); else if (dlevel > 18 && !rn2(6)) mkswamp(); #endif /* QUEST */ } int makerooms() { struct rectangle *rsp; int lx, ly, hx, hy, lowx, lowy, hix, hiy, dx, dy; int tryct = 0, xlim, ylim; /* init */ xlim = XLIM + secret; ylim = YLIM + secret; if (nroom == 0) { rsp = rs; rsp->rlx = rsp->rly = 0; rsp->rhx = COLNO - 1; rsp->rhy = ROWNO - 1; rsmax = 1; } rscnt = rsmax; /* make rooms until satisfied */ while (rscnt > 0 && nroom < MAXNROFROOMS - 1) { if (!secret && nroom > (MAXNROFROOMS / 3) && !rn2((MAXNROFROOMS - nroom) * (MAXNROFROOMS - nroom))) return (0); /* pick a rectangle */ rsp = &rs[rn2(rscnt)]; hx = rsp->rhx; hy = rsp->rhy; lx = rsp->rlx; ly = rsp->rly; /* find size of room */ if (secret) dx = dy = 1; else { dx = 2 + rn2((hx - lx - 8 > 20) ? 12 : 8); dy = 2 + rn2(4); if (dx * dy > 50) dy = 50 / dx; } /* look whether our room will fit */ if (hx - lx < dx + dx / 2 + 2 * xlim || hy - ly < dy + dy / 3 + 2 * ylim) { /* no, too small */ /* maybe we throw this area out */ if (secret || !rn2(MAXNROFROOMS + 1 - nroom - tryct)) { rscnt--; rs[rsmax] = *rsp; *rsp = rs[rscnt]; rs[rscnt] = rs[rsmax]; tryct = 0; } else tryct++; continue; } lowx = lx + xlim + rn2(hx - lx - dx - 2 * xlim + 1); lowy = ly + ylim + rn2(hy - ly - dy - 2 * ylim + 1); hix = lowx + dx; hiy = lowy + dy; if (maker(lowx, dx, lowy, dy)) { if (secret) return (1); addrs(lowx - 1, lowy - 1, hix + 1, hiy + 1); tryct = 0; } else if (tryct++ > 100) break; } return (0); /* failed to make vault - very strange */ } void addrs(lowx, lowy, hix, hiy) int lowx, lowy, hix, hiy; { struct rectangle *rsp; int lx, ly, hx, hy, xlim, ylim; boolean discarded; xlim = XLIM + secret; ylim = YLIM + secret; /* walk down since rscnt and rsmax change */ for (rsp = &rs[rsmax - 1]; rsp >= rs; rsp--) { if ((lx = rsp->rlx) > hix || (ly = rsp->rly) > hiy || (hx = rsp->rhx) < lowx || (hy = rsp->rhy) < lowy) continue; if ((discarded = (rsp >= &rs[rscnt]))) { *rsp = rs[--rsmax]; } else { rsmax--; rscnt--; *rsp = rs[rscnt]; if (rscnt != rsmax) rs[rscnt] = rs[rsmax]; } if (lowy - ly > 2 * ylim + 4) addrsx(lx, ly, hx, lowy - 2, discarded); if (lowx - lx > 2 * xlim + 4) addrsx(lx, ly, lowx - 2, hy, discarded); if (hy - hiy > 2 * ylim + 4) addrsx(lx, hiy + 2, hx, hy, discarded); if (hx - hix > 2 * xlim + 4) addrsx(hix + 2, ly, hx, hy, discarded); } } void addrsx(lx, ly, hx, hy, discarded) int lx, ly, hx, hy; boolean discarded; /* piece of a discarded area */ { struct rectangle *rsp; /* check inclusions */ for (rsp = rs; rsp < &rs[rsmax]; rsp++) { if (lx >= rsp->rlx && hx <= rsp->rhx && ly >= rsp->rly && hy <= rsp->rhy) return; } /* make a new entry */ if (rsmax >= MAXRS) { #ifdef WIZARD if (wizard) pline("MAXRS may be too small."); #endif /* WIZARD */ return; } rsmax++; if (!discarded) { *rsp = rs[rscnt]; rsp = &rs[rscnt]; rscnt++; } rsp->rlx = lx; rsp->rly = ly; rsp->rhx = hx; rsp->rhy = hy; } int comp(vx, vy) const void *vx, *vy; { const struct mkroom *x = vx, *y = vy; if (x->lx < y->lx) return (-1); return (x->lx > y->lx); } coord finddpos(int xl, int yl, int xh, int yh) { coord ff; int x, y; x = (xl == xh) ? xl : (xl + rn2(xh - xl + 1)); y = (yl == yh) ? yl : (yl + rn2(yh - yl + 1)); if (okdoor(x, y)) goto gotit; for (x = xl; x <= xh; x++) for (y = yl; y <= yh; y++) if (okdoor(x, y)) goto gotit; for (x = xl; x <= xh; x++) for (y = yl; y <= yh; y++) if (levl[x][y].typ == DOOR || levl[x][y].typ == SDOOR) goto gotit; /* cannot find something reasonable -- strange */ x = xl; y = yh; gotit: ff.x = x; ff.y = y; return (ff); } /* see whether it is allowable to create a door at [x,y] */ int okdoor(x, y) int x, y; { if (levl[x - 1][y].typ == DOOR || levl[x + 1][y].typ == DOOR || levl[x][y + 1].typ == DOOR || levl[x][y - 1].typ == DOOR || levl[x - 1][y].typ == SDOOR || levl[x + 1][y].typ == SDOOR || levl[x][y - 1].typ == SDOOR || levl[x][y + 1].typ == SDOOR || (levl[x][y].typ != HWALL && levl[x][y].typ != VWALL) || doorindex >= DOORMAX) return (0); return (1); } void dodoor(x, y, aroom) int x, y; struct mkroom *aroom; { if (doorindex >= DOORMAX) { impossible("DOORMAX exceeded?"); return; } if (!okdoor(x, y) && nxcor) return; dosdoor(x, y, aroom, rn2(8) ? DOOR : SDOOR); } void dosdoor(x, y, aroom, type) int x, y; struct mkroom *aroom; int type; { struct mkroom *broom; int tmp; if (!IS_WALL(levl[x][y].typ)) /* avoid SDOORs with '+' as scrsym */ type = DOOR; levl[x][y].typ = type; if (type == DOOR) levl[x][y].scrsym = '+'; aroom->doorct++; broom = aroom + 1; if (broom->hx < 0) tmp = doorindex; else for (tmp = doorindex; tmp > broom->fdoor; tmp--) doors[tmp] = doors[tmp - 1]; doorindex++; doors[tmp].x = x; doors[tmp].y = y; for (; broom->hx >= 0; broom++) broom->fdoor++; } /* Only called from makerooms() */ int maker(lowx, ddx, lowy, ddy) schar lowx, ddx, lowy, ddy; { struct mkroom *croom; int x, y, hix = lowx + ddx, hiy = lowy + ddy; int xlim = XLIM + secret, ylim = YLIM + secret; if (nroom >= MAXNROFROOMS) return (0); if (lowx < XLIM) lowx = XLIM; if (lowy < YLIM) lowy = YLIM; if (hix > COLNO - XLIM - 1) hix = COLNO - XLIM - 1; if (hiy > ROWNO - YLIM - 1) hiy = ROWNO - YLIM - 1; chk: if (hix <= lowx || hiy <= lowy) return (0); /* check area around room (and make room smaller if necessary) */ for (x = lowx - xlim; x <= hix + xlim; x++) { for (y = lowy - ylim; y <= hiy + ylim; y++) { if (levl[x][y].typ) { #ifdef WIZARD if (wizard && !secret) pline("Strange area [%d,%d] in maker().", x, y); #endif /* WIZARD */ if (!rn2(3)) return (0); if (x < lowx) lowx = x + xlim + 1; else hix = x - xlim - 1; if (y < lowy) lowy = y + ylim + 1; else hiy = y - ylim - 1; goto chk; } } } croom = &rooms[nroom]; /* on low levels the room is lit (usually) */ /* secret vaults are always lit */ if ((rnd(dlevel) < 10 && rn2(77)) || (ddx == 1 && ddy == 1)) { for (x = lowx - 1; x <= hix + 1; x++) for (y = lowy - 1; y <= hiy + 1; y++) levl[x][y].lit = 1; croom->rlit = 1; } else croom->rlit = 0; croom->lx = lowx; croom->hx = hix; croom->ly = lowy; croom->hy = hiy; croom->rtype = croom->doorct = croom->fdoor = 0; for (x = lowx - 1; x <= hix + 1; x++) for (y = lowy - 1; y <= hiy + 1; y += (hiy - lowy + 2)) { levl[x][y].scrsym = '-'; levl[x][y].typ = HWALL; } for (x = lowx - 1; x <= hix + 1; x += (hix - lowx + 2)) for (y = lowy; y <= hiy; y++) { levl[x][y].scrsym = '|'; levl[x][y].typ = VWALL; } for (x = lowx; x <= hix; x++) for (y = lowy; y <= hiy; y++) { levl[x][y].scrsym = '.'; levl[x][y].typ = ROOM; } smeq[nroom] = nroom; croom++; croom->hx = -1; nroom++; return (1); } void makecorridors() { int a, b; nxcor = 0; for (a = 0; a < nroom - 1; a++) join(a, a + 1); for (a = 0; a < nroom - 2; a++) if (smeq[a] != smeq[a + 2]) join(a, a + 2); for (a = 0; a < nroom; a++) for (b = 0; b < nroom; b++) if (smeq[a] != smeq[b]) join(a, b); if (nroom > 2) for (nxcor = rn2(nroom) + 4; nxcor; nxcor--) { a = rn2(nroom); b = rn2(nroom - 2); if (b >= a) b += 2; join(a, b); } } void join(a, b) int a, b; { coord cc, tt; int tx, ty, xx, yy; struct rm *crm; struct mkroom *croom, *troom; int dx, dy, dix, diy, cct; croom = &rooms[a]; troom = &rooms[b]; /* * find positions cc and tt for doors in croom and troom and * direction for a corridor between them */ if (troom->hx < 0 || croom->hx < 0 || doorindex >= DOORMAX) return; if (troom->lx > croom->hx) { dx = 1; dy = 0; xx = croom->hx + 1; tx = troom->lx - 1; cc = finddpos(xx, croom->ly, xx, croom->hy); tt = finddpos(tx, troom->ly, tx, troom->hy); } else if (troom->hy < croom->ly) { dy = -1; dx = 0; yy = croom->ly - 1; cc = finddpos(croom->lx, yy, croom->hx, yy); ty = troom->hy + 1; tt = finddpos(troom->lx, ty, troom->hx, ty); } else if (troom->hx < croom->lx) { dx = -1; dy = 0; xx = croom->lx - 1; tx = troom->hx + 1; cc = finddpos(xx, croom->ly, xx, croom->hy); tt = finddpos(tx, troom->ly, tx, troom->hy); } else { dy = 1; dx = 0; yy = croom->hy + 1; ty = troom->ly - 1; cc = finddpos(croom->lx, yy, croom->hx, yy); tt = finddpos(troom->lx, ty, troom->hx, ty); } xx = cc.x; yy = cc.y; tx = tt.x - dx; ty = tt.y - dy; if (nxcor && levl[xx + dx][yy + dy].typ) return; dodoor(xx, yy, croom); cct = 0; while (xx != tx || yy != ty) { xx += dx; yy += dy; /* loop: dig corridor at [xx,yy] and find new [xx,yy] */ if (cct++ > 500 || (nxcor && !rn2(35))) return; if (xx == COLNO - 1 || xx == 0 || yy == 0 || yy == ROWNO - 1) return; /* impossible */ crm = &levl[xx][yy]; if (!(crm->typ)) { if (rn2(100)) { crm->typ = CORR; crm->scrsym = CORR_SYM; if (nxcor && !rn2(50)) (void) mkobj_at(ROCK_SYM, xx, yy); } else { crm->typ = SCORR; crm->scrsym = ' '; } } else if (crm->typ != CORR && crm->typ != SCORR) { /* strange ... */ return; } /* find next corridor position */ dix = abs(xx - tx); diy = abs(yy - ty); /* do we have to change direction ? */ if (dy && dix > diy) { int ddx = (xx > tx) ? -1 : 1; crm = &levl[xx + ddx][yy]; if (!crm->typ || crm->typ == CORR || crm->typ == SCORR) { dx = ddx; dy = 0; continue; } } else if (dx && diy > dix) { int ddy = (yy > ty) ? -1 : 1; crm = &levl[xx][yy + ddy]; if (!crm->typ || crm->typ == CORR || crm->typ == SCORR) { dy = ddy; dx = 0; continue; } } /* continue straight on? */ crm = &levl[xx + dx][yy + dy]; if (!crm->typ || crm->typ == CORR || crm->typ == SCORR) continue; /* no, what must we do now?? */ if (dx) { dx = 0; dy = (ty < yy) ? -1 : 1; crm = &levl[xx + dx][yy + dy]; if (!crm->typ || crm->typ == CORR || crm->typ == SCORR) continue; dy = -dy; continue; } else { dy = 0; dx = (tx < xx) ? -1 : 1; crm = &levl[xx + dx][yy + dy]; if (!crm->typ || crm->typ == CORR || crm->typ == SCORR) continue; dx = -dx; continue; } } /* we succeeded in digging the corridor */ dodoor(tt.x, tt.y, troom); if (smeq[a] < smeq[b]) smeq[b] = smeq[a]; else smeq[a] = smeq[b]; } void make_niches() { int ct = rnd(nroom / 2 + 1); while (ct--) makeniche(FALSE); } void makevtele() { makeniche(TRUE); } void makeniche(with_trap) boolean with_trap; { struct mkroom *aroom; struct rm *rm; int vct = 8; coord dd; int dy, xx, yy; struct trap *ttmp; if (doorindex < DOORMAX) while (vct--) { aroom = &rooms[rn2(nroom - 1)]; if (aroom->rtype != 0) continue; /* not an ordinary room */ if (aroom->doorct == 1 && rn2(5)) continue; if (rn2(2)) { dy = 1; dd = finddpos(aroom->lx, aroom->hy + 1, aroom->hx, aroom->hy + 1); } else { dy = -1; dd = finddpos(aroom->lx, aroom->ly - 1, aroom->hx, aroom->ly - 1); } xx = dd.x; yy = dd.y; if ((rm = &levl[xx][yy + dy])->typ) continue; if (with_trap || !rn2(4)) { rm->typ = SCORR; rm->scrsym = ' '; if (with_trap) { ttmp = maketrap(xx, yy + dy, TELEP_TRAP); ttmp->once = 1; make_engr_at(xx, yy - dy, "ad ae?ar um"); } dosdoor(xx, yy, aroom, SDOOR); } else { rm->typ = CORR; rm->scrsym = CORR_SYM; if (rn2(7)) dosdoor(xx, yy, aroom, rn2(5) ? SDOOR : DOOR); else { mksobj_at(SCR_TELEPORTATION, xx, yy + dy); if (!rn2(3)) (void) mkobj_at(0, xx, yy + dy); } } return; } } /* make a trap somewhere (in croom if mazeflag = 0) */ void mktrap(num, mazeflag, croom) int num, mazeflag; struct mkroom *croom; { struct trap *ttmp; int kind, nopierc, nomimic, fakedoor, fakegold, tryct = 0; xchar mx, my; if (!num || num >= TRAPNUM) { nopierc = (dlevel < 4) ? 1 : 0; nomimic = (dlevel < 9 || goldseen) ? 1 : 0; if (strchr(fut_geno, 'M')) nomimic = 1; kind = rn2(TRAPNUM - nopierc - nomimic); /* note: PIERC = 7, MIMIC = 8, TRAPNUM = 9 */ } else kind = num; if (kind == MIMIC) { struct monst *mtmp; fakedoor = (!rn2(3) && !mazeflag); fakegold = (!fakedoor && !rn2(2)); if (fakegold) goldseen = TRUE; do { if (++tryct > 200) return; if (fakedoor) { /* note: fakedoor maybe on actual door */ if (rn2(2)) { if (rn2(2)) mx = croom->hx + 1; else mx = croom->lx - 1; my = somey(); } else { if (rn2(2)) my = croom->hy + 1; else my = croom->ly - 1; mx = somex(); } } else if (mazeflag) { coord mm; mm = mazexy(); mx = mm.x; my = mm.y; } else { mx = somex(); my = somey(); } } while (m_at(mx, my) || levl[mx][my].typ == STAIRS); if ((mtmp = makemon(PM_MIMIC, mx, my)) != NULL) { mtmp->mimic = 1; mtmp->mappearance = fakegold ? '$' : fakedoor ? '+' : (mazeflag && rn2(2)) ? AMULET_SYM : "=/)%?![<>"[rn2(9)]; } return; } do { if (++tryct > 200) return; if (mazeflag) { coord mm; mm = mazexy(); mx = mm.x; my = mm.y; } else { mx = somex(); my = somey(); } } while (t_at(mx, my) || levl[mx][my].typ == STAIRS); ttmp = maketrap(mx, my, kind); if (mazeflag && !rn2(10) && ttmp->ttyp < PIERC) ttmp->tseen = 1; } bsd-games-2.17/hack/hack.topl.c0000664000175000017500000001623207767741711014761 0ustar jsm28jsm28/* $NetBSD: hack.topl.c,v 1.7 2003/04/02 18:36:41 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.topl.c,v 1.7 2003/04/02 18:36:41 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" char toplines[BUFSZ]; xchar tlx, tly; /* set by pline; used by addtopl */ struct topl { struct topl *next_topl; char *topl_text; } *old_toplines, *last_redone_topl; #define OTLMAX 20 /* max nr of old toplines remembered */ int doredotopl() { if (last_redone_topl) last_redone_topl = last_redone_topl->next_topl; if (!last_redone_topl) last_redone_topl = old_toplines; if (last_redone_topl) { (void) strcpy(toplines, last_redone_topl->topl_text); } redotoplin(); return (0); } void redotoplin() { home(); if (strchr(toplines, '\n')) cl_end(); putstr(toplines); cl_end(); tlx = curx; tly = cury; flags.toplin = 1; if (tly > 1) more(); } void remember_topl() { struct topl *tl; int cnt = OTLMAX; if (last_redone_topl && !strcmp(toplines, last_redone_topl->topl_text)) return; if (old_toplines && !strcmp(toplines, old_toplines->topl_text)) return; last_redone_topl = 0; tl = (struct topl *) alloc((unsigned) (strlen(toplines) + sizeof(struct topl) + 1)); tl->next_topl = old_toplines; tl->topl_text = (char *) (tl + 1); (void) strcpy(tl->topl_text, toplines); old_toplines = tl; while (cnt && tl) { cnt--; tl = tl->next_topl; } if (tl && tl->next_topl) { free((char *) tl->next_topl); tl->next_topl = 0; } } void addtopl(s) const char *s; { curs(tlx, tly); if (tlx + (int)strlen(s) > CO) putsym('\n'); putstr(s); tlx = curx; tly = cury; flags.toplin = 1; } void xmore(s) const char *s; /* allowed chars besides space/return */ { if (flags.toplin) { curs(tlx, tly); if (tlx + 8 > CO) putsym('\n'), tly++; } if (flags.standout) standoutbeg(); putstr("--More--"); if (flags.standout) standoutend(); xwaitforspace(s); if (flags.toplin && tly > 1) { home(); cl_end(); docorner(1, tly - 1); } flags.toplin = 0; } void more() { xmore(""); } void cmore(s) const char *s; { xmore(s); } void clrlin() { if (flags.toplin) { home(); cl_end(); if (tly > 1) docorner(1, tly - 1); remember_topl(); } flags.toplin = 0; } void pline(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vpline(fmt, ap); va_end(ap); } void vpline(line, ap) const char *line; va_list ap; { char pbuf[BUFSZ]; char *bp = pbuf, *tl; int n, n0; if (!line || !*line) return; if (!strchr(line, '%')) (void) strcpy(pbuf, line); else (void) vsprintf(pbuf, line, ap); if (flags.toplin == 1 && !strcmp(pbuf, toplines)) return; nscr(); /* %% */ /* If there is room on the line, print message on same line */ /* But messages like "You die..." deserve their own line */ n0 = strlen(bp); if (flags.toplin == 1 && tly == 1 && n0 + (int)strlen(toplines) + 3 < CO - 8 && /* leave room for * --More-- */ strncmp(bp, "You ", 4)) { (void) strcat(toplines, " "); (void) strcat(toplines, bp); tlx += 2; addtopl(bp); return; } if (flags.toplin == 1) more(); remember_topl(); toplines[0] = 0; while (n0) { if (n0 >= CO) { /* look for appropriate cut point */ n0 = 0; for (n = 0; n < CO; n++) if (bp[n] == ' ') n0 = n; if (!n0) for (n = 0; n < CO - 1; n++) if (!letter(bp[n])) n0 = n; if (!n0) n0 = CO - 2; } (void) strncpy((tl = eos(toplines)), bp, n0); tl[n0] = 0; bp += n0; /* remove trailing spaces, but leave one */ while (n0 > 1 && tl[n0 - 1] == ' ' && tl[n0 - 2] == ' ') tl[--n0] = 0; n0 = strlen(bp); if (n0 && tl[0]) (void) strcat(tl, "\n"); } redotoplin(); } void putsym(c) char c; { switch (c) { case '\b': backsp(); return; case '\n': curx = 1; cury++; if (cury > tly) tly = cury; break; default: if (curx == CO) putsym('\n'); /* 1 <= curx <= CO; avoid CO */ else curx++; } (void) putchar(c); } void putstr(s) const char *s; { while (*s) putsym(*s++); } bsd-games-2.17/hack/COPYRIGHT0000664000175000017500000000311307767741711014217 0ustar jsm28jsm28$NetBSD: COPYRIGHT,v 1.3 2003/04/02 18:36:33 jsm Exp $ Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, Amsterdam All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Stichting Centrum voor Wiskunde en Informatica, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. bsd-games-2.17/hack/hack.unix.c0000664000175000017500000003277207767741711014775 0ustar jsm28jsm28/* $NetBSD: hack.unix.c,v 1.9 2003/04/02 18:36:41 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.unix.c,v 1.9 2003/04/02 18:36:41 jsm Exp $"); #endif /* not lint */ /* This file collects some Unix dependencies; hack.pager.c contains some more */ /* * The time is used for: * - seed for random() * - year on tombstone and yymmdd in record file * - phase of the moon (various monsters react to NEW_MOON or FULL_MOON) * - night and midnight (the undead are dangerous at midnight) * - determination of what files are "very old" */ #include #include /* for time_t and stat */ #include #ifdef BSD #include #else #include #endif /* BSD */ #include #include #include #include #include "hack.h" /* mainly for strchr() which depends on BSD */ #include "extern.h" extern int locknum; void setrandom() { (void) srandom((int) time((time_t *) 0)); } struct tm * getlt() { time_t date; (void) time(&date); return (localtime(&date)); } int getyear() { return (1900 + getlt()->tm_year); } char * getdate() { static char datestr[7]; struct tm *lt = getlt(); (void) sprintf(datestr, "%02d%02d%02d", lt->tm_year % 100, lt->tm_mon + 1, lt->tm_mday); return (datestr); } int phase_of_the_moon() { /* 0-7, with 0: new, 4: full *//* moon * period: 29.5306 days */ /* year: 365.2422 days */ struct tm *lt = getlt(); int epact, diy, golden; diy = lt->tm_yday; golden = (lt->tm_year % 19) + 1; epact = (11 * golden + 18) % 30; if ((epact == 25 && golden > 11) || epact == 24) epact++; return ((((((diy + epact) * 6) + 11) % 177) / 22) & 7); } int night() { int hour = getlt()->tm_hour; return (hour < 6 || hour > 21); } int midnight() { return (getlt()->tm_hour == 0); } struct stat buf, hbuf; void gethdate(name) char *name; { #if 0 /* old version - for people short of space */ char *np; if(stat(name, &hbuf)) error("Cannot get status of %s.", (np = strrchr(name, '/')) ? np+1 : name); #else /* version using PATH from: seismo!gregc@ucsf-cgl.ARPA (Greg Couch) */ /* * The problem with #include is that this include file * does not exist on all systems, and moreover, that it sometimes includes * again, so that the compiler sees these typedefs twice. */ #define MAXPATHLEN 1024 const char *np, *path; char filename[MAXPATHLEN + 1]; if (strchr(name, '/') != NULL || (path = getenv("PATH")) == NULL) path = ""; for (;;) { if ((np = strchr(path, ':')) == NULL) np = path + strlen(path); /* point to end str */ if (np - path <= 1) /* %% */ (void) strcpy(filename, name); else { (void) strncpy(filename, path, np - path); filename[np - path] = '/'; (void) strcpy(filename + (np - path) + 1, name); } if (stat(filename, &hbuf) == 0) return; if (*np == '\0') break; path = np + 1; } error("Cannot get status of %s.", (np = strrchr(name, '/')) ? np + 1 : name); #endif } int uptodate(int fd) { if (fstat(fd, &buf)) { pline("Cannot get status of saved level? "); return (0); } if (buf.st_mtime < hbuf.st_mtime) { pline("Saved level is out of date. "); return (0); } return (1); } /* see whether we should throw away this xlock file */ int veryold(fd) int fd; { int i; time_t date; if (fstat(fd, &buf)) return (0); /* cannot get status */ if (buf.st_size != sizeof(int)) return (0); /* not an xlock file */ (void) time(&date); if (date - buf.st_mtime < 3L * 24L * 60L * 60L) { /* recent */ int lockedpid; /* should be the same size as * hackpid */ if (read(fd, (char *) &lockedpid, sizeof(lockedpid)) != sizeof(lockedpid)) /* strange ... */ return (0); /* * From: Rick Adams This will work on * 4.1cbsd, 4.2bsd and system 3? & 5. It will do nothing * on V7 or 4.1bsd. */ if (!(kill(lockedpid, 0) == -1 && errno == ESRCH)) return (0); } (void) close(fd); for (i = 1; i <= MAXLEVEL; i++) { /* try to remove all */ glo(i); (void) unlink(lock); } glo(0); if (unlink(lock)) return (0); /* cannot remove it */ return (1); /* success! */ } void getlock() { int i = 0, fd; (void) fflush(stdout); /* we ignore QUIT and INT at this point */ if (link(HLOCK, LLOCK) == -1) { int errnosv = errno; perror(HLOCK); printf("Cannot link %s to %s\n", LLOCK, HLOCK); switch (errnosv) { case ENOENT: printf("Perhaps there is no (empty) file %s ?\n", HLOCK); break; case EACCES: printf("It seems you don't have write permission here.\n"); break; case EEXIST: printf("(Try again or rm %s.)\n", LLOCK); break; default: printf("I don't know what is wrong."); } getret(); error("%s", ""); /* NOTREACHED */ } regularize(lock); glo(0); if (locknum > 25) locknum = 25; do { if (locknum) lock[0] = 'a' + i++; if ((fd = open(lock, O_RDONLY)) == -1) { if (errno == ENOENT) goto gotlock; /* no such file */ perror(lock); (void) unlink(LLOCK); error("Cannot open %s", lock); } if (veryold(fd))/* if true, this closes fd and unlinks lock */ goto gotlock; (void) close(fd); } while (i < locknum); (void) unlink(LLOCK); error(locknum ? "Too many hacks running now." : "There is a game in progress under your name."); gotlock: fd = creat(lock, FMASK); if (unlink(LLOCK) == -1) error("Cannot unlink %s.", LLOCK); if (fd == -1) { error("cannot creat lock file."); } else { if (write(fd, (char *) &hackpid, sizeof(hackpid)) != sizeof(hackpid)) { error("cannot write lock"); } if (close(fd) == -1) { error("cannot close lock"); } } } #ifdef MAIL /* * Notify user when new mail has arrived. [Idea from Merlyn Leroy, but * I don't know the details of his implementation.] * { Later note: he disliked my calling a general mailreader and felt that * hack should do the paging itself. But when I get mail, I want to put it * in some folder, reply, etc. - it would be unreasonable to put all these * functions in hack. } * The mail daemon '2' is at present not a real monster, but only a visual * effect. Thus, makemon() is superfluous. This might become otherwise, * however. The motion of '2' is less restrained than usual: diagonal moves * from a DOOR are possible. He might also use SDOOR's. Also, '2' is visible * in a ROOM, even when you are Blind. * Its path should be longer when you are Telepat-hic and Blind. * * Interesting side effects: * - You can get rich by sending yourself a lot of mail and selling * it to the shopkeeper. Unfortunately mail isn't very valuable. * - You might die in case '2' comes along at a critical moment during * a fight and delivers a scroll the weight of which causes you to * collapse. * * Possible extensions: * - Open the file MAIL and do fstat instead of stat for efficiency. * (But sh uses stat, so this cannot be too bad.) * - Examine the mail and produce a scroll of mail called "From somebody". * - Invoke MAILREADER in such a way that only this single letter is read. * * - Make him lose his mail when a Nymph steals the letter. * - Do something to the text when the scroll is enchanted or cancelled. */ #include "def.mkroom.h" static struct stat omstat, nmstat; static char *mailbox; static long laststattime; void getmailstatus() { if (!(mailbox = getenv("MAIL"))) return; if (stat(mailbox, &omstat)) { #ifdef PERMANENT_MAILBOX pline("Cannot get status of MAIL=%s .", mailbox); mailbox = 0; #else omstat.st_mtime = 0; #endif /* PERMANENT_MAILBOX */ } } void ckmailstatus() { if (!mailbox #ifdef MAILCKFREQ || moves < laststattime + MAILCKFREQ #endif /* MAILCKFREQ */ ) return; laststattime = moves; if (stat(mailbox, &nmstat)) { #ifdef PERMANENT_MAILBOX pline("Cannot get status of MAIL=%s anymore.", mailbox); mailbox = 0; #else nmstat.st_mtime = 0; #endif /* PERMANENT_MAILBOX */ } else if (nmstat.st_mtime > omstat.st_mtime) { if (nmstat.st_size) newmail(); getmailstatus();/* might be too late ... */ } } void newmail() { /* produce a scroll of mail */ struct obj *obj; struct monst *md; obj = mksobj(SCR_MAIL); if (md = makemon(&pm_mail_daemon, u.ux, u.uy)) /* always succeeds */ mdrush(md, 0); pline("\"Hello, %s! I have some mail for you.\"", plname); if (md) { if (dist(md->mx, md->my) > 2) pline("\"Catch!\""); more(); /* let him disappear again */ mdrush(md, 1); mondead(md); } obj = addinv(obj); (void) identify(obj); /* set known and do prinv() */ } /* make md run through the cave */ void mdrush(md, away) struct monst *md; boolean away; { int uroom = inroom(u.ux, u.uy); if (uroom >= 0) { int tmp = rooms[uroom].fdoor; int cnt = rooms[uroom].doorct; int fx = u.ux, fy = u.uy; while (cnt--) { if (dist(fx, fy) < dist(doors[tmp].x, doors[tmp].y)) { fx = doors[tmp].x; fy = doors[tmp].y; } tmp++; } tmp_at(-1, md->data->mlet); /* open call */ if (away) { /* interchange origin and destination */ unpmon(md); tmp = fx; fx = md->mx; md->mx = tmp; tmp = fy; fy = md->my; md->my = tmp; } while (fx != md->mx || fy != md->my) { int dx, dy, nfx = fx, nfy = fy, d1, d2; tmp_at(fx, fy); d1 = DIST(fx, fy, md->mx, md->my); for (dx = -1; dx <= 1; dx++) for (dy = -1; dy <= 1; dy++) if (dx || dy) { d2 = DIST(fx + dx, fy + dy, md->mx, md->my); if (d2 < d1) { d1 = d2; nfx = fx + dx; nfy = fy + dy; } } if (nfx != fx || nfy != fy) { fx = nfx; fy = nfy; } else { if (!away) { md->mx = fx; md->my = fy; } break; } } tmp_at(-1, -1); /* close call */ } if (!away) pmon(md); } void readmail() { #ifdef DEF_MAILREADER /* This implies that UNIX is defined */ char *mr = 0; more(); if (!(mr = getenv("MAILREADER"))) mr = DEF_MAILREADER; if (child(1)) { execl(mr, mr, (char *) 0); exit(1); } #else /* DEF_MAILREADER */ (void) page_file(mailbox, FALSE); #endif /* DEF_MAILREADER */ /* * get new stat; not entirely correct: there is a small time window * where we do not see new mail */ getmailstatus(); } #endif /* MAIL */ void regularize(s) /* normalize file name - we don't like ..'s * or /'s */ char *s; { char *lp; while ((lp = strchr(s, '.')) || (lp = strchr(s, '/'))) *lp = '_'; } bsd-games-2.17/hack/hack.apply.c0000664000175000017500000003325510005547567015124 0ustar jsm28jsm28/* $NetBSD: hack.apply.c,v 1.8 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.apply.c,v 1.8 2004/01/27 20:30:29 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #include "def.edog.h" #include "def.mkroom.h" static void use_camera(struct obj *); static int in_ice_box(struct obj *); static int ck_ice_box(struct obj *); static int out_ice_box(struct obj *); static void use_ice_box(struct obj *); static struct monst *bchit(int, int , int , int); static void use_whistle(struct obj *); static void use_magic_whistle(struct obj *); static int dig(void); static int use_pick_axe(struct obj *); int doapply() { struct obj *obj; int res = 1; obj = getobj("(", "use or apply"); if (!obj) return (0); switch (obj->otyp) { case EXPENSIVE_CAMERA: use_camera(obj); break; case ICE_BOX: use_ice_box(obj); break; case PICK_AXE: res = use_pick_axe(obj); break; case MAGIC_WHISTLE: if (pl_character[0] == 'W' || u.ulevel > 9) { use_magic_whistle(obj); break; } /* fall into next case */ case WHISTLE: use_whistle(obj); break; case CAN_OPENER: if (!carrying(TIN)) { pline("You have no can to open."); goto xit; } pline("You cannot open a tin without eating its contents."); pline("In order to eat, use the 'e' command."); if (obj != uwep) pline("Opening the tin will be much easier if you wield the can-opener."); goto xit; default: pline("Sorry, I don't know how to use that."); xit: nomul(0); return (0); } nomul(0); return (res); } /* ARGSUSED */ static void use_camera(obj) /* */ struct obj *obj __attribute__((__unused__)); { struct monst *mtmp; if (!getdir(1)) { /* ask: in what direction? */ flags.move = multi = 0; return; } if (u.uswallow) { pline("You take a picture of %s's stomach.", monnam(u.ustuck)); return; } if (u.dz) { pline("You take a picture of the %s.", (u.dz > 0) ? "floor" : "ceiling"); return; } if ((mtmp = bchit(u.dx, u.dy, COLNO, '!')) != NULL) { if (mtmp->msleep) { mtmp->msleep = 0; pline("The flash awakens %s.", monnam(mtmp)); /* a3 */ } else if (mtmp->data->mlet != 'y') if (mtmp->mcansee || mtmp->mblinded) { int tmp = dist(mtmp->mx, mtmp->my); int tmp2; if (cansee(mtmp->mx, mtmp->my)) pline("%s is blinded by the flash!", Monnam(mtmp)); setmangry(mtmp); if (tmp < 9 && !mtmp->isshk && rn2(4)) { mtmp->mflee = 1; if (rn2(4)) mtmp->mfleetim = rnd(100); } if (tmp < 3) mtmp->mcansee = mtmp->mblinded = 0; else { tmp2 = mtmp->mblinded; tmp2 += rnd(1 + 50 / tmp); if (tmp2 > 127) tmp2 = 127; mtmp->mblinded = tmp2; mtmp->mcansee = 0; } } } } static struct obj *current_ice_box;/* a local variable of use_ice_box, to be * used by its local procedures in/ck_ice_box */ static int in_ice_box(obj) struct obj *obj; { if (obj == current_ice_box || (Punished && (obj == uball || obj == uchain))) { pline("You must be kidding."); return (0); } if (obj->owornmask & (W_ARMOR | W_RING)) { pline("You cannot refrigerate something you are wearing."); return (0); } if (obj->owt + current_ice_box->owt > 70) { pline("It won't fit."); return (1); /* be careful! */ } if (obj == uwep) { if (uwep->cursed) { pline("Your weapon is welded to your hand!"); return (0); } setuwep((struct obj *) 0); } current_ice_box->owt += obj->owt; freeinv(obj); obj->o_cnt_id = current_ice_box->o_id; obj->nobj = fcobj; fcobj = obj; obj->age = moves - obj->age; /* actual age */ return (1); } static int ck_ice_box(obj) struct obj *obj; { return (obj->o_cnt_id == current_ice_box->o_id); } static int out_ice_box(obj) struct obj *obj; { struct obj *otmp; if (obj == fcobj) fcobj = fcobj->nobj; else { for (otmp = fcobj; otmp->nobj != obj; otmp = otmp->nobj) if (!otmp->nobj) panic("out_ice_box"); otmp->nobj = obj->nobj; } current_ice_box->owt -= obj->owt; obj->age = moves - obj->age; /* simulated point of time */ (void) addinv(obj); return 0; } static void use_ice_box(obj) struct obj *obj; { int cnt = 0; struct obj *otmp; current_ice_box = obj; /* for use by in/out_ice_box */ for (otmp = fcobj; otmp; otmp = otmp->nobj) if (otmp->o_cnt_id == obj->o_id) cnt++; if (!cnt) pline("Your ice-box is empty."); else { pline("Do you want to take something out of the ice-box? [yn] "); if (readchar() == 'y') if (askchain(fcobj, (char *) 0, 0, out_ice_box, ck_ice_box, 0)) return; pline("That was all. Do you wish to put something in? [yn] "); if (readchar() != 'y') return; } /* call getobj: 0: allow cnt; #: allow all types; %: expect food */ otmp = getobj("0#%", "put in"); if (!otmp || !in_ice_box(otmp)) flags.move = multi = 0; } static struct monst * bchit(ddx, ddy, range, sym) int ddx, ddy, range; char sym; { struct monst *mtmp = (struct monst *) 0; int bchx = u.ux, bchy = u.uy; if (sym) Tmp_at(-1, sym);/* open call */ while (range--) { bchx += ddx; bchy += ddy; if ((mtmp = m_at(bchx, bchy)) != NULL) break; if (!ZAP_POS(levl[bchx][bchy].typ)) { bchx -= ddx; bchy -= ddy; break; } if (sym) Tmp_at(bchx, bchy); } if (sym) Tmp_at(-1, -1); return (mtmp); } /* ARGSUSED */ static void use_whistle(obj) struct obj *obj __attribute__((__unused__)); { struct monst *mtmp = fmon; pline("You produce a high whistling sound."); while (mtmp) { if (dist(mtmp->mx, mtmp->my) < u.ulevel * 20) { if (mtmp->msleep) mtmp->msleep = 0; if (mtmp->mtame) EDOG(mtmp)->whistletime = moves; } mtmp = mtmp->nmon; } } /* ARGSUSED */ static void use_magic_whistle(obj) struct obj *obj __attribute__((__unused__)); { struct monst *mtmp = fmon; pline("You produce a strange whistling sound."); while (mtmp) { if (mtmp->mtame) mnexto(mtmp); mtmp = mtmp->nmon; } } static int dig_effort; /* effort expended on current pos */ static uchar dig_level; static coord dig_pos; static boolean dig_down; static int dig() { struct rm *lev; int dpx = dig_pos.x, dpy = dig_pos.y; /* perhaps a nymph stole his pick-axe while he was busy digging */ /* or perhaps he teleported away */ if (u.uswallow || !uwep || uwep->otyp != PICK_AXE || dig_level != dlevel || ((dig_down && (dpx != u.ux || dpy != u.uy)) || (!dig_down && dist(dpx, dpy) > 2))) return (0); dig_effort += 10 + abon() + uwep->spe + rn2(5); if (dig_down) { if (!xdnstair) { pline("The floor here seems too hard to dig in."); return (0); } if (dig_effort > 250) { dighole(); return (0); /* done with digging */ } if (dig_effort > 50) { struct trap *ttmp = t_at(dpx, dpy); if (!ttmp) { ttmp = maketrap(dpx, dpy, PIT); ttmp->tseen = 1; pline("You have dug a pit."); u.utrap = rn1(4, 2); u.utraptype = TT_PIT; return (0); } } } else if (dig_effort > 100) { const char *digtxt; struct obj *obj; lev = &levl[dpx][dpy]; if ((obj = sobj_at(ENORMOUS_ROCK, dpx, dpy)) != NULL) { fracture_rock(obj); digtxt = "The rock falls apart."; } else if (!lev->typ || lev->typ == SCORR) { lev->typ = CORR; digtxt = "You succeeded in cutting away some rock."; } else if (lev->typ == HWALL || lev->typ == VWALL || lev->typ == SDOOR) { lev->typ = xdnstair ? DOOR : ROOM; digtxt = "You just made an opening in the wall."; } else digtxt = "Now what exactly was it that you were digging in?"; mnewsym(dpx, dpy); prl(dpx, dpy); pline(digtxt); /* after mnewsym & prl */ return (0); } else { if (IS_WALL(levl[dpx][dpy].typ)) { int rno = inroom(dpx, dpy); if (rno >= 0 && rooms[rno].rtype >= 8) { pline("This wall seems too hard to dig into."); return (0); } } pline("You hit the rock with all your might."); } return (1); } /* When will hole be finished? Very rough indication used by shopkeeper. */ int holetime() { return ((occupation == dig) ? (250 - dig_effort) / 20 : -1); } void dighole() { struct trap *ttmp = t_at(u.ux, u.uy); if (!xdnstair) { pline("The floor here seems too hard to dig in."); } else { if (ttmp) ttmp->ttyp = TRAPDOOR; else ttmp = maketrap(u.ux, u.uy, TRAPDOOR); ttmp->tseen = 1; pline("You've made a hole in the floor."); if (!u.ustuck) { if (inshop()) shopdig(1); pline("You fall through ..."); if (u.utraptype == TT_PIT) { u.utrap = 0; u.utraptype = 0; } goto_level(dlevel + 1, FALSE); } } } static int use_pick_axe(obj) struct obj *obj; { char dirsyms[12]; char *dsp = dirsyms, *sdp = sdir; struct monst *mtmp; struct rm *lev; int rx, ry, res = 0; if (obj != uwep) { if (uwep && uwep->cursed) { /* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */ pline("Since your weapon is welded to your hand,"); pline("you cannot use that pick-axe."); return (0); } pline("You now wield %s.", doname(obj)); setuwep(obj); res = 1; } while (*sdp) { (void) movecmd(*sdp); /* sets u.dx and u.dy and u.dz */ rx = u.ux + u.dx; ry = u.uy + u.dy; if (u.dz > 0 || (u.dz == 0 && isok(rx, ry) && (IS_ROCK(levl[rx][ry].typ) || sobj_at(ENORMOUS_ROCK, rx, ry)))) *dsp++ = *sdp; sdp++; } *dsp = 0; pline("In what direction do you want to dig? [%s] ", dirsyms); if (!getdir(0)) /* no txt */ return (res); if (u.uswallow && attack(u.ustuck)) /* return(1) */ ; else if (u.dz < 0) pline("You cannot reach the ceiling."); else if (u.dz == 0) { if (Confusion) confdir(); rx = u.ux + u.dx; ry = u.uy + u.dy; if ((mtmp = m_at(rx, ry)) && attack(mtmp)) return (1); if (!isok(rx, ry)) { pline("Clash!"); return (1); } lev = &levl[rx][ry]; if (lev->typ == DOOR) pline("Your %s against the door.", aobjnam(obj, "clang")); else if (!IS_ROCK(lev->typ) && !sobj_at(ENORMOUS_ROCK, rx, ry)) { /* ACCESSIBLE or POOL */ pline("You swing your %s through thin air.", aobjnam(obj, (char *) 0)); } else { if (dig_pos.x != rx || dig_pos.y != ry || dig_level != dlevel || dig_down) { dig_down = FALSE; dig_pos.x = rx; dig_pos.y = ry; dig_level = dlevel; dig_effort = 0; pline("You start digging."); } else pline("You continue digging."); occupation = dig; occtxt = "digging"; } } else if (Levitation) { pline("You cannot reach the floor."); } else { if (dig_pos.x != u.ux || dig_pos.y != u.uy || dig_level != dlevel || !dig_down) { dig_down = TRUE; dig_pos.x = u.ux; dig_pos.y = u.uy; dig_level = dlevel; dig_effort = 0; pline("You start digging in the floor."); if (inshop()) shopdig(0); } else pline("You continue digging in the floor."); occupation = dig; occtxt = "digging"; } return (1); } bsd-games-2.17/hack/hack.version.c0000664000175000017500000000672707767741711015500 0ustar jsm28jsm28/* $NetBSD: hack.version.c,v 1.5 2003/04/02 18:36:41 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.version.c,v 1.5 2003/04/02 18:36:41 jsm Exp $"); #endif /* not lint */ #include "date.h" #include "hack.h" #include "extern.h" int doversion() { pline("%s 1.0.3 - last edit %s.", ( #ifdef QUEST "Quest" #else "Hack" #endif /* QUEST */ ), datestring); return (0); } bsd-games-2.17/hack/hack.mhitu.c0000664000175000017500000002644407767741711015137 0ustar jsm28jsm28/* $NetBSD: hack.mhitu.c,v 1.6 2003/04/02 18:36:37 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.mhitu.c,v 1.6 2003/04/02 18:36:37 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" /* * mhitu: monster hits you * returns 1 if monster dies (e.g. 'y', 'F'), 0 otherwise */ int mhitu(mtmp) struct monst *mtmp; { const struct permonst *mdat = mtmp->data; int tmp, ctmp; nomul(0); /* If swallowed, can only be affected by hissers and by u.ustuck */ if (u.uswallow) { if (mtmp != u.ustuck) { if (mdat->mlet == 'c' && !rn2(13)) { pline("Outside, you hear %s's hissing!", monnam(mtmp)); pline("%s gets turned to stone!", Monnam(u.ustuck)); pline("And the same fate befalls you."); done_in_by(mtmp); /* "notreached": not return(1); */ } return (0); } switch (mdat->mlet) { /* now mtmp == u.ustuck */ case ',': youswld(mtmp, (u.uac > 0) ? u.uac + 4 : 4, 5, "The trapper"); break; case '\'': youswld(mtmp, rnd(6), 7, "The lurker above"); break; case 'P': youswld(mtmp, d(2, 4), 12, "The purple worm"); break; default: /* This is not impossible! */ pline("The mysterious monster totally digests you."); u.uhp = 0; } if (u.uhp < 1) done_in_by(mtmp); return (0); } if (mdat->mlet == 'c' && Stoned) return (0); /* make eels visible the moment they hit/miss us */ if (mdat->mlet == ';' && mtmp->minvis && cansee(mtmp->mx, mtmp->my)) { mtmp->minvis = 0; pmon(mtmp); } if (!strchr("1&DuxynNF", mdat->mlet)) tmp = hitu(mtmp, d(mdat->damn, mdat->damd)); else tmp = 0; if (strchr(UNDEAD, mdat->mlet) && midnight()) tmp += hitu(mtmp, d(mdat->damn, mdat->damd)); ctmp = tmp && !mtmp->mcan && (!uarm || objects[uarm->otyp].a_can < rnd(3) || !rn2(50)); switch (mdat->mlet) { case '1': if (wiz_hit(mtmp)) return (1); /* he disappeared */ break; case '&': if (!mtmp->cham && !mtmp->mcan && !rn2(13)) { (void) makemon(PM_DEMON, u.ux, u.uy); } else { (void) hitu(mtmp, d(2, 6)); (void) hitu(mtmp, d(2, 6)); (void) hitu(mtmp, rnd(3)); (void) hitu(mtmp, rnd(3)); (void) hitu(mtmp, rn1(4, 2)); } break; case ',': if (tmp) justswld(mtmp, "The trapper"); break; case '\'': if (tmp) justswld(mtmp, "The lurker above"); break; case ';': if (ctmp) { if (!u.ustuck && !rn2(10)) { pline("%s swings itself around you!", Monnam(mtmp)); u.ustuck = mtmp; } else if (u.ustuck == mtmp && levl[mtmp->mx][mtmp->my].typ == POOL) { pline("%s drowns you ...", Monnam(mtmp)); done("drowned"); } } break; case 'A': if (ctmp && rn2(2)) { if (Poison_resistance) pline("The sting doesn't seem to affect you."); else { pline("You feel weaker!"); losestr(1); } } break; case 'C': (void) hitu(mtmp, rnd(6)); break; case 'c': if (!rn2(5)) { pline("You hear %s's hissing!", monnam(mtmp)); if (ctmp || !rn2(20) || (flags.moonphase == NEW_MOON && !carrying(DEAD_LIZARD))) { Stoned = 5; /* pline("You get turned to stone!"); */ /* done_in_by(mtmp); */ } } break; case 'D': if (rn2(6) || mtmp->mcan) { (void) hitu(mtmp, d(3, 10)); (void) hitu(mtmp, rnd(8)); (void) hitu(mtmp, rnd(8)); break; } kludge("%s breathes fire!", "The dragon"); buzz(-1, mtmp->mx, mtmp->my, u.ux - mtmp->mx, u.uy - mtmp->my); break; case 'd': (void) hitu(mtmp, d(2, (flags.moonphase == FULL_MOON) ? 3 : 4)); break; case 'e': (void) hitu(mtmp, d(3, 6)); break; case 'F': if (mtmp->mcan) break; kludge("%s explodes!", "The freezing sphere"); if (Cold_resistance) pline("You don't seem affected by it."); else { xchar dn; if (17 - (u.ulevel / 2) > rnd(20)) { pline("You get blasted!"); dn = 6; } else { pline("You duck the blast..."); dn = 3; } losehp_m(d(dn, 6), mtmp); } mondead(mtmp); return (1); case 'g': if (ctmp && multi >= 0 && !rn2(3)) { kludge("You are frozen by %ss juices", "the cube'"); nomul(-rnd(10)); } break; case 'h': if (ctmp && multi >= 0 && !rn2(5)) { nomul(-rnd(10)); kludge("You are put to sleep by %ss bite!", "the homunculus'"); } break; case 'j': tmp = hitu(mtmp, rnd(3)); tmp &= hitu(mtmp, rnd(3)); if (tmp) { (void) hitu(mtmp, rnd(4)); (void) hitu(mtmp, rnd(4)); } break; case 'k': if ((hitu(mtmp, rnd(4)) || !rn2(3)) && ctmp) { poisoned("bee's sting", mdat->mname); } break; case 'L': if (tmp) stealgold(mtmp); break; case 'N': if (mtmp->mcan && !Blind) { pline("%s tries to seduce you, but you seem not interested.", Amonnam(mtmp, "plain")); if (rn2(3)) rloc(mtmp); } else if (steal(mtmp)) { rloc(mtmp); mtmp->mflee = 1; } break; case 'n': if (!uwep && !uarm && !uarmh && !uarms && !uarmg) { pline("%s hits! (I hope you don't mind)", Monnam(mtmp)); u.uhp += rnd(7); if (!rn2(7)) u.uhpmax++; if (u.uhp > u.uhpmax) u.uhp = u.uhpmax; flags.botl = 1; if (!rn2(50)) rloc(mtmp); } else { (void) hitu(mtmp, d(2, 6)); (void) hitu(mtmp, d(2, 6)); } break; case 'o': tmp = hitu(mtmp, rnd(6)); if (hitu(mtmp, rnd(6)) && tmp && /* hits with both paws */ !u.ustuck && rn2(2)) { u.ustuck = mtmp; kludge("%s has grabbed you!", "The owlbear"); u.uhp -= d(2, 8); } else if (u.ustuck == mtmp) { u.uhp -= d(2, 8); pline("You are being crushed."); } break; case 'P': if (ctmp && !rn2(4)) justswld(mtmp, "The purple worm"); else (void) hitu(mtmp, d(2, 4)); break; case 'Q': (void) hitu(mtmp, rnd(2)); (void) hitu(mtmp, rnd(2)); break; case 'R': if (tmp && uarmh && !uarmh->rustfree && (int) uarmh->spe >= -1) { pline("Your helmet rusts!"); uarmh->spe--; } else if (ctmp && uarm && !uarm->rustfree && /* Mike Newton */ uarm->otyp < STUDDED_LEATHER_ARMOR && (int) uarm->spe >= -1) { pline("Your armor rusts!"); uarm->spe--; } break; case 'S': if (ctmp && !rn2(8)) { poisoned("snake's bite", mdat->mname); } break; case 's': if (tmp && !rn2(8)) { poisoned("scorpion's sting", mdat->mname); } (void) hitu(mtmp, rnd(8)); (void) hitu(mtmp, rnd(8)); break; case 'T': (void) hitu(mtmp, rnd(6)); (void) hitu(mtmp, rnd(6)); break; case 't': if (!rn2(5)) rloc(mtmp); break; case 'u': mtmp->mflee = 1; break; case 'U': (void) hitu(mtmp, d(3, 4)); (void) hitu(mtmp, d(3, 4)); break; case 'v': if (ctmp && !u.ustuck) u.ustuck = mtmp; break; case 'V': if (tmp) u.uhp -= 4; if (ctmp) losexp(); break; case 'W': if (ctmp) losexp(); break; #ifndef NOWORM case 'w': if (tmp) wormhit(mtmp); #endif /* NOWORM */ break; case 'X': (void) hitu(mtmp, rnd(5)); (void) hitu(mtmp, rnd(5)); (void) hitu(mtmp, rnd(5)); break; case 'x': { long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE; pline("%s pricks in your %s leg!", Monnam(mtmp), (side == RIGHT_SIDE) ? "right" : "left"); set_wounded_legs(side, rnd(50)); losehp_m(2, mtmp); break; } case 'y': if (mtmp->mcan) break; mondead(mtmp); if (!Blind) { pline("You are blinded by a blast of light!"); Blind = d(4, 12); seeoff(0); } return (1); case 'Y': (void) hitu(mtmp, rnd(6)); break; } if (u.uhp < 1) done_in_by(mtmp); return (0); } int hitu(mtmp, dam) struct monst *mtmp; int dam; { int tmp, res; nomul(0); if (u.uswallow) return (0); if (mtmp->mhide && mtmp->mundetected) { mtmp->mundetected = 0; if (!Blind) { struct obj *obj; if ((obj = o_at(mtmp->mx, mtmp->my)) != NULL) pline("%s was hidden under %s!", Xmonnam(mtmp), doname(obj)); } } tmp = u.uac; /* give people with Ac = -10 at least some vulnerability */ if (tmp < 0) { dam += tmp; /* decrease damage */ if (dam <= 0) dam = 1; tmp = -rn2(-tmp); } tmp += mtmp->data->mlevel; if (multi < 0) tmp += 4; if ((Invis && mtmp->data->mlet != 'I') || !mtmp->mcansee) tmp -= 2; if (mtmp->mtrapped) tmp -= 2; if (tmp <= rnd(20)) { if (Blind) pline("It misses."); else pline("%s misses.", Monnam(mtmp)); res = 0; } else { if (Blind) pline("It hits!"); else pline("%s hits!", Monnam(mtmp)); losehp_m(dam, mtmp); res = 1; } stop_occupation(); return (res); } bsd-games-2.17/hack/hack.mon.c0000664000175000017500000006106107767741711014574 0ustar jsm28jsm28/* $NetBSD: hack.mon.c,v 1.6 2003/04/02 18:36:38 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.mon.c,v 1.6 2003/04/02 18:36:38 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" #include "hack.mfndpos.h" #ifndef NULL #define NULL (char *) 0 #endif int warnlevel; /* used by movemon and dochugw */ long lastwarntime; int lastwarnlev; const char *const warnings[] = { "white", "pink", "red", "ruby", "purple", "black" }; void movemon() { struct monst *mtmp; int fr; warnlevel = 0; while (1) { /* find a monster that we haven't treated yet */ /* * note that mtmp or mtmp->nmon might get killed while mtmp * moves, so we cannot just walk down the chain (even new * monsters might get created!) */ for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp->mlstmv < moves) goto next_mon; /* treated all monsters */ break; next_mon: mtmp->mlstmv = moves; /* most monsters drown in pools */ { boolean inpool, iseel; inpool = (levl[mtmp->mx][mtmp->my].typ == POOL); iseel = (mtmp->data->mlet == ';'); if (inpool && !iseel) { if (cansee(mtmp->mx, mtmp->my)) pline("%s drowns.", Monnam(mtmp)); mondead(mtmp); continue; } /* but eels have a difficult time outside */ if (iseel && !inpool) { if (mtmp->mhp > 1) mtmp->mhp--; mtmp->mflee = 1; mtmp->mfleetim += 2; } } if (mtmp->mblinded && !--mtmp->mblinded) mtmp->mcansee = 1; if (mtmp->mfleetim && !--mtmp->mfleetim) mtmp->mflee = 0; if (mtmp->mimic) continue; if (mtmp->mspeed != MSLOW || !(moves % 2)) { /* continue if the monster died fighting */ fr = -1; if (Conflict && cansee(mtmp->mx, mtmp->my) && (fr = fightm(mtmp)) == 2) continue; if (fr < 0 && dochugw(mtmp)) continue; } if (mtmp->mspeed == MFAST && dochugw(mtmp)) continue; } warnlevel -= u.ulevel; if (warnlevel >= SIZE(warnings)) warnlevel = SIZE(warnings) - 1; if (warnlevel >= 0) if (warnlevel > lastwarnlev || moves > lastwarntime + 5) { const char *rr; switch (Warning & (LEFT_RING | RIGHT_RING)) { case LEFT_RING: rr = "Your left ring glows"; break; case RIGHT_RING: rr = "Your right ring glows"; break; case LEFT_RING | RIGHT_RING: rr = "Both your rings glow"; break; default: rr = "Your fingertips glow"; break; } pline("%s %s!", rr, warnings[warnlevel]); lastwarntime = moves; lastwarnlev = warnlevel; } dmonsfree(); /* remove all dead monsters */ } void justswld(mtmp, name) struct monst *mtmp; const char *name; { mtmp->mx = u.ux; mtmp->my = u.uy; u.ustuck = mtmp; pmon(mtmp); kludge("%s swallows you!", name); more(); seeoff(1); u.uswallow = 1; u.uswldtim = 0; swallowed(); } void youswld(mtmp, dam, die, name) struct monst *mtmp; int dam, die; const char *name; { if (mtmp != u.ustuck) return; kludge("%s digests you!", name); u.uhp -= dam; if ((int)u.uswldtim++ >= die) { /* a3 */ pline("It totally digests you!"); u.uhp = -1; } if (u.uhp < 1) done_in_by(mtmp); #if 0 flags.botlx = 1; /* should we show status line ? */ #endif } int dochugw(mtmp) struct monst *mtmp; { int x = mtmp->mx; int y = mtmp->my; int d = dochug(mtmp); int dd; if (!d) /* monster still alive */ if (Warning) if (!mtmp->mpeaceful) if (mtmp->data->mlevel > warnlevel) if ((dd = dist(mtmp->mx, mtmp->my)) < dist(x, y)) if (dd < 100) if (!canseemon(mtmp)) warnlevel = mtmp->data->mlevel; return (d); } /* returns 1 if monster died moving, 0 otherwise */ int dochug(mtmp) struct monst *mtmp; { const struct permonst *mdat; int tmp = 0, nearby, scared; if (mtmp->cham && !rn2(6)) (void) newcham(mtmp, &mons[dlevel + 14 + rn2(CMNUM - 14 - dlevel)]); mdat = mtmp->data; if (mdat->mlevel < 0) panic("bad monster %c (%d)", mdat->mlet, mdat->mlevel); /* regenerate monsters */ if ((!(moves % 20) || strchr(MREGEN, mdat->mlet)) && mtmp->mhp < mtmp->mhpmax) mtmp->mhp++; if (mtmp->mfroz) return (0); /* frozen monsters don't do anything */ if (mtmp->msleep) { /* wake up, or get out of here. */ /* ettins are hard to surprise */ /* Nymphs and Leprechauns do not easily wake up */ if (cansee(mtmp->mx, mtmp->my) && (!Stealth || (mdat->mlet == 'e' && rn2(10))) && (!strchr("NL", mdat->mlet) || !rn2(50)) && (Aggravate_monster || strchr("d1", mdat->mlet) || (!rn2(7) && !mtmp->mimic))) mtmp->msleep = 0; else return (0); } /* not frozen or sleeping: wipe out texts written in the dust */ wipe_engr_at(mtmp->mx, mtmp->my, 1); /* confused monsters get unconfused with small probability */ if (mtmp->mconf && !rn2(50)) mtmp->mconf = 0; /* some monsters teleport */ if (mtmp->mflee && strchr("tNL", mdat->mlet) && !rn2(40)) { rloc(mtmp); return (0); } if (mdat->mmove < rnd(6)) return (0); /* fleeing monsters might regain courage */ if (mtmp->mflee && !mtmp->mfleetim && mtmp->mhp == mtmp->mhpmax && !rn2(25)) mtmp->mflee = 0; nearby = (dist(mtmp->mx, mtmp->my) < 3); scared = (nearby && (sengr_at("Elbereth", u.ux, u.uy) || sobj_at(SCR_SCARE_MONSTER, u.ux, u.uy))); if (scared && !mtmp->mflee) { mtmp->mflee = 1; mtmp->mfleetim = (rn2(7) ? rnd(10) : rnd(100)); } if (!nearby || mtmp->mflee || mtmp->mconf || (mtmp->minvis && !rn2(3)) || (strchr("BIuy", mdat->mlet) && !rn2(4)) || (mdat->mlet == 'L' && !u.ugold && (mtmp->mgold || rn2(2))) || (!mtmp->mcansee && !rn2(4)) || mtmp->mpeaceful ) { tmp = m_move(mtmp, 0); /* 2: monster died moving */ if (tmp == 2 || (tmp && mdat->mmove <= 12)) return (tmp == 2); } if (!strchr("Ea", mdat->mlet) && nearby && !mtmp->mpeaceful && u.uhp > 0 && !scared) { if (mhitu(mtmp)) return (1); /* monster died (e.g. 'y' or 'F') */ } /* extra movement for fast monsters */ if (mdat->mmove - 12 > rnd(12)) tmp = m_move(mtmp, 1); return (tmp == 2); } int m_move(struct monst *mtmp, int after) { struct monst *mtmp2; int nx, ny, omx, omy, appr, nearer, cnt, i, j; xchar gx, gy, nix, niy, chcnt; schar chi; boolean likegold = 0, likegems = 0, likeobjs = 0; char msym = mtmp->data->mlet; schar mmoved = 0; /* not strictly nec.: chi >= 0 will * do */ coord poss[9]; int info[9]; if (mtmp->mfroz || mtmp->msleep) return (0); if (mtmp->mtrapped) { i = mintrap(mtmp); if (i == 2) return (2); /* he died */ if (i == 1) return (0); /* still in trap, so didnt move */ } if (mtmp->mhide && o_at(mtmp->mx, mtmp->my) && rn2(10)) return (0); /* do not leave hiding place */ #ifndef NOWORM if (mtmp->wormno) goto not_special; #endif /* NOWORM */ /* my dog gets a special treatment */ if (mtmp->mtame) { return (dog_move(mtmp, after)); } /* likewise for shopkeeper */ if (mtmp->isshk) { mmoved = shk_move(mtmp); if (mmoved >= 0) goto postmov; mmoved = 0; /* follow player outside shop */ } /* and for the guard */ if (mtmp->isgd) { mmoved = gd_move(); goto postmov; } /* * teleport if that lies in our nature ('t') or when badly wounded * ('1') */ if ((msym == 't' && !rn2(5)) || (msym == '1' && (mtmp->mhp < 7 || (!xdnstair && !rn2(5)) || levl[u.ux][u.uy].typ == STAIRS))) { if (mtmp->mhp < 7 || (msym == 't' && rn2(2))) rloc(mtmp); else mnexto(mtmp); mmoved = 1; goto postmov; } /* spit fire ('D') or use a wand ('1') when appropriate */ if (strchr("D1", msym)) inrange(mtmp); if (msym == 'U' && !mtmp->mcan && canseemon(mtmp) && mtmp->mcansee && rn2(5)) { if (!Confusion) pline("%s's gaze has confused you!", Monnam(mtmp)); else pline("You are getting more and more confused."); if (rn2(3)) mtmp->mcan = 1; Confusion += d(3, 4); /* timeout */ } not_special: if (!mtmp->mflee && u.uswallow && u.ustuck != mtmp) return (1); appr = 1; if (mtmp->mflee) appr = -1; if (mtmp->mconf || Invis || !mtmp->mcansee || (strchr("BIy", msym) && !rn2(3))) appr = 0; omx = mtmp->mx; omy = mtmp->my; gx = u.ux; gy = u.uy; if (msym == 'L' && appr == 1 && mtmp->mgold > u.ugold) appr = -1; /* * random criterion for 'smell' or track finding ability should use * mtmp->msmell or sth */ if (msym == '@' || ('a' <= msym && msym <= 'z')) { coord *cp; schar mroom; mroom = inroom(omx, omy); if (mroom < 0 || mroom != inroom(u.ux, u.uy)) { cp = gettrack(omx, omy); if (cp) { gx = cp->x; gy = cp->y; } } } /* look for gold or jewels nearby */ likegold = (strchr("LOD", msym) != NULL); likegems = (strchr("ODu", msym) != NULL); likeobjs = mtmp->mhide; #define SRCHRADIUS 25 { xchar mind = SRCHRADIUS; /* not too far away */ int dd; if (likegold) { struct gold *gold; for (gold = fgold; gold; gold = gold->ngold) if ((dd = DIST(omx, omy, gold->gx, gold->gy)) < mind) { mind = dd; gx = gold->gx; gy = gold->gy; } } if (likegems || likeobjs) { struct obj *otmp; for (otmp = fobj; otmp; otmp = otmp->nobj) if (likeobjs || otmp->olet == GEM_SYM) if (msym != 'u' || objects[otmp->otyp].g_val != 0) if ((dd = DIST(omx, omy, otmp->ox, otmp->oy)) < mind) { mind = dd; gx = otmp->ox; gy = otmp->oy; } } if (mind < SRCHRADIUS && appr == -1) { if (dist(omx, omy) < 10) { gx = u.ux; gy = u.uy; } else appr = 1; } } nix = omx; niy = omy; cnt = mfndpos(mtmp, poss, info, msym == 'u' ? NOTONL : (msym == '@' || msym == '1') ? (ALLOW_SSM | ALLOW_TRAPS) : strchr(UNDEAD, msym) ? NOGARLIC : ALLOW_TRAPS); /* ALLOW_ROCK for some monsters ? */ chcnt = 0; chi = -1; for (i = 0; i < cnt; i++) { nx = poss[i].x; ny = poss[i].y; for (j = 0; j < MTSZ && j < cnt - 1; j++) if (nx == mtmp->mtrack[j].x && ny == mtmp->mtrack[j].y) if (rn2(4 * (cnt - j))) goto nxti; #ifdef STUPID /* some stupid compilers think that this is too complicated */ { int d1 = DIST(nx, ny, gx, gy); int d2 = DIST(nix, niy, gx, gy); nearer = (d1 < d2); } #else nearer = (DIST(nx, ny, gx, gy) < DIST(nix, niy, gx, gy)); #endif /* STUPID */ if ((appr == 1 && nearer) || (appr == -1 && !nearer) || !mmoved || (!appr && !rn2(++chcnt))) { nix = nx; niy = ny; chi = i; mmoved = 1; } nxti: ; } if (mmoved) { if (info[chi] & ALLOW_M) { mtmp2 = m_at(nix, niy); if (hitmm(mtmp, mtmp2) == 1 && rn2(4) && hitmm(mtmp2, mtmp) == 2) return (2); return (0); } if (info[chi] & ALLOW_U) { (void) hitu(mtmp, d(mtmp->data->damn, mtmp->data->damd) + 1); return (0); } mtmp->mx = nix; mtmp->my = niy; for (j = MTSZ - 1; j > 0; j--) mtmp->mtrack[j] = mtmp->mtrack[j - 1]; mtmp->mtrack[0].x = omx; mtmp->mtrack[0].y = omy; #ifndef NOWORM if (mtmp->wormno) worm_move(mtmp); #endif /* NOWORM */ } else { if (msym == 'u' && rn2(2)) { rloc(mtmp); return (0); } #ifndef NOWORM if (mtmp->wormno) worm_nomove(mtmp); #endif /* NOWORM */ } postmov: if (mmoved == 1) { if (mintrap(mtmp) == 2) /* he died */ return (2); if (likegold) mpickgold(mtmp); if (likegems) mpickgems(mtmp); if (mtmp->mhide) mtmp->mundetected = 1; } pmon(mtmp); return (mmoved); } void mpickgold(mtmp) struct monst *mtmp; { struct gold *gold; while ((gold = g_at(mtmp->mx, mtmp->my)) != NULL) { mtmp->mgold += gold->amount; freegold(gold); if (levl[mtmp->mx][mtmp->my].scrsym == '$') newsym(mtmp->mx, mtmp->my); } } void mpickgems(mtmp) struct monst *mtmp; { struct obj *otmp; for (otmp = fobj; otmp; otmp = otmp->nobj) if (otmp->olet == GEM_SYM) if (otmp->ox == mtmp->mx && otmp->oy == mtmp->my) if (mtmp->data->mlet != 'u' || objects[otmp->otyp].g_val != 0) { freeobj(otmp); mpickobj(mtmp, otmp); if (levl[mtmp->mx][mtmp->my].scrsym == GEM_SYM) newsym(mtmp->mx, mtmp->my); /* %% */ return; /* pick only one object */ } } /* return number of acceptable neighbour positions */ int mfndpos(mon, poss, info, flag) struct monst *mon; coord poss[9]; int info[9], flag; { int x, y, nx, ny, cnt = 0, ntyp; struct monst *mtmp; int nowtyp; boolean pool; x = mon->mx; y = mon->my; nowtyp = levl[x][y].typ; pool = (mon->data->mlet == ';'); nexttry: /* eels prefer the water, but if there is no * water nearby, they will crawl over land */ if (mon->mconf) { flag |= ALLOW_ALL; flag &= ~NOTONL; } for (nx = x - 1; nx <= x + 1; nx++) for (ny = y - 1; ny <= y + 1; ny++) if (nx != x || ny != y) if (isok(nx, ny)) if (!IS_ROCK(ntyp = levl[nx][ny].typ)) if (!(nx != x && ny != y && (nowtyp == DOOR || ntyp == DOOR))) if ((ntyp == POOL) == pool) { info[cnt] = 0; if (nx == u.ux && ny == u.uy) { if (!(flag & ALLOW_U)) continue; info[cnt] = ALLOW_U; } else if ((mtmp = m_at(nx, ny)) != NULL) { if (!(flag & ALLOW_M)) continue; info[cnt] = ALLOW_M; if (mtmp->mtame) { if (!(flag & ALLOW_TM)) continue; info[cnt] |= ALLOW_TM; } } if (sobj_at(CLOVE_OF_GARLIC, nx, ny)) { if (flag & NOGARLIC) continue; info[cnt] |= NOGARLIC; } if (sobj_at(SCR_SCARE_MONSTER, nx, ny) || (!mon->mpeaceful && sengr_at("Elbereth", nx, ny))) { if (!(flag & ALLOW_SSM)) continue; info[cnt] |= ALLOW_SSM; } if (sobj_at(ENORMOUS_ROCK, nx, ny)) { if (!(flag & ALLOW_ROCK)) continue; info[cnt] |= ALLOW_ROCK; } if (!Invis && online(nx, ny)) { if (flag & NOTONL) continue; info[cnt] |= NOTONL; } /* * we cannot * avoid * traps of * an unknown * kind */ { struct trap *ttmp = t_at(nx, ny); int tt; if (ttmp) { tt = 1 << ttmp->ttyp; if (mon->mtrapseen & tt) { if (!(flag & tt)) continue; info[cnt] |= tt; } } } poss[cnt].x = nx; poss[cnt].y = ny; cnt++; } if (!cnt && pool && nowtyp != POOL) { pool = FALSE; goto nexttry; } return (cnt); } int dist(x, y) int x, y; { return ((x - u.ux) * (x - u.ux) + (y - u.uy) * (y - u.uy)); } void poisoned(string, pname) const char *string, *pname; { int i; if (Blind) pline("It was poisoned."); else pline("The %s was poisoned!", string); if (Poison_resistance) { pline("The poison doesn't seem to affect you."); return; } i = rn2(10); if (i == 0) { u.uhp = -1; pline("I am afraid the poison was deadly ..."); } else if (i <= 5) { losestr(rn1(3, 3)); } else { losehp(rn1(10, 6), pname); } if (u.uhp < 1) { killer = pname; done("died"); } } void mondead(mtmp) struct monst *mtmp; { relobj(mtmp, 1); unpmon(mtmp); relmon(mtmp); unstuck(mtmp); if (mtmp->isshk) shkdead(mtmp); if (mtmp->isgd) gddead(); #ifndef NOWORM if (mtmp->wormno) wormdead(mtmp); #endif /* NOWORM */ monfree(mtmp); } /* called when monster is moved to larger structure */ void replmon(mtmp, mtmp2) struct monst *mtmp, *mtmp2; { relmon(mtmp); monfree(mtmp); mtmp2->nmon = fmon; fmon = mtmp2; if (u.ustuck == mtmp) u.ustuck = mtmp2; if (mtmp2->isshk) replshk(mtmp, mtmp2); if (mtmp2->isgd) replgd(mtmp, mtmp2); } void relmon(mon) struct monst *mon; { struct monst *mtmp; if (mon == fmon) fmon = fmon->nmon; else { for (mtmp = fmon; mtmp->nmon != mon; mtmp = mtmp->nmon); mtmp->nmon = mon->nmon; } } /* * we do not free monsters immediately, in order to have their name available * shortly after their demise */ struct monst *fdmon; /* chain of dead monsters, need not to be * saved */ void monfree(mtmp) struct monst *mtmp; { mtmp->nmon = fdmon; fdmon = mtmp; } void dmonsfree() { struct monst *mtmp; while ((mtmp = fdmon) != NULL) { fdmon = mtmp->nmon; free((char *) mtmp); } } void unstuck(mtmp) struct monst *mtmp; { if (u.ustuck == mtmp) { if (u.uswallow) { u.ux = mtmp->mx; u.uy = mtmp->my; u.uswallow = 0; setsee(); docrt(); } u.ustuck = 0; } } void killed(mtmp) struct monst *mtmp; { #ifdef lint #define NEW_SCORING #endif /* lint */ int tmp, nk, x, y; const struct permonst *mdat; if (mtmp->cham) mtmp->data = PM_CHAMELEON; mdat = mtmp->data; if (Blind) pline("You destroy it!"); else { pline("You destroy %s!", mtmp->mtame ? amonnam(mtmp, "poor") : monnam(mtmp)); } if (u.umconf) { if (!Blind) pline("Your hands stop glowing blue."); u.umconf = 0; } /* count killed monsters */ #define MAXMONNO 100 nk = 1; /* in case we cannot find it in mons */ tmp = mdat - mons; /* strchr in mons array (if not 'd', '@', ...) */ if (tmp >= 0 && tmp < CMNUM + 2) { u.nr_killed[tmp]++; if ((nk = u.nr_killed[tmp]) > MAXMONNO && !strchr(fut_geno, mdat->mlet)) charcat(fut_geno, mdat->mlet); } /* punish bad behaviour */ if (mdat->mlet == '@') Telepat = 0, u.uluck -= 2; if (mtmp->mpeaceful || mtmp->mtame) u.uluck--; if (mdat->mlet == 'u') u.uluck -= 5; if ((int) u.uluck < LUCKMIN) u.uluck = LUCKMIN; /* give experience points */ tmp = 1 + mdat->mlevel * mdat->mlevel; if (mdat->ac < 3) tmp += 2 * (7 - mdat->ac); if (strchr("AcsSDXaeRTVWU&In:P", mdat->mlet)) tmp += 2 * mdat->mlevel; if (strchr("DeV&P", mdat->mlet)) tmp += (7 * mdat->mlevel); if (mdat->mlevel > 6) tmp += 50; if (mdat->mlet == ';') tmp += 1000; #ifdef NEW_SCORING /* * ------- recent addition: make nr of points decrease when this is * not the first of this kind */ { int ul = u.ulevel; int ml = mdat->mlevel; if (ul < 14) /* points are given based on present and * future level */ for (tmp2 = 0; !tmp2 || ul + tmp2 <= ml; tmp2++) if (u.uexp + 1 + (tmp + ((tmp2 <= 0) ? 0 : 4 << (tmp2 - 1))) / nk >= 10 * pow((unsigned) (ul - 1))) if (++ul == 14) break; tmp2 = ml - ul - 1; tmp = (tmp + ((tmp2 < 0) ? 0 : 4 << tmp2)) / nk; if (!tmp) tmp = 1; } /* note: ul is not necessarily the future value of u.ulevel */ /* ------- end of recent valuation change ------- */ #endif /* NEW_SCORING */ more_experienced(tmp, 0); flags.botl = 1; while (u.ulevel < 14 && u.uexp >= newuexp()) { pline("Welcome to experience level %u.", ++u.ulevel); tmp = rnd(10); if (tmp < 3) tmp = rnd(10); u.uhpmax += tmp; u.uhp += tmp; flags.botl = 1; } /* dispose of monster and make cadaver */ x = mtmp->mx; y = mtmp->my; mondead(mtmp); tmp = mdat->mlet; if (tmp == 'm') { /* he killed a minotaur, give him a wand of * digging */ /* note: the dead minotaur will be on top of it! */ mksobj_at(WAN_DIGGING, x, y); /* if(cansee(x,y)) atl(x,y,fobj->olet); */ stackobj(fobj); } else #ifndef NOWORM if (tmp == 'w') { mksobj_at(WORM_TOOTH, x, y); stackobj(fobj); } else #endif /* NOWORM */ if (!letter(tmp) || (!strchr("mw", tmp) && !rn2(3))) tmp = 0; if (ACCESSIBLE(levl[x][y].typ)) /* might be mimic in wall or dead eel */ if (x != u.ux || y != u.uy) /* might be here after * swallowed */ if (strchr("NTVm&", mdat->mlet) || rn2(5)) { struct obj *obj2 = mkobj_at(tmp, x, y); if (cansee(x, y)) atl(x, y, obj2->olet); stackobj(obj2); } } void kludge(const char *str, const char *arg) { if (Blind) { if (*str == '%') pline(str, "It"); else pline(str, "it"); } else pline(str, arg); } void rescham() { /* force all chameleons to become normal */ struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp->cham) { mtmp->cham = 0; (void) newcham(mtmp, PM_CHAMELEON); } } int newcham(mtmp, mdat) /* make a chameleon look like a new monster */ /* returns 1 if the monster actually changed */ struct monst *mtmp; const struct permonst *mdat; { int mhp, hpn, hpd; if (mdat == mtmp->data) return (0); /* still the same monster */ #ifndef NOWORM if (mtmp->wormno) wormdead(mtmp); /* throw tail away */ #endif /* NOWORM */ if (u.ustuck == mtmp) { if (u.uswallow) { u.uswallow = 0; u.uswldtim = 0; mnexto(mtmp); docrt(); prme(); } u.ustuck = 0; } hpn = mtmp->mhp; hpd = (mtmp->data->mlevel) * 8; if (!hpd) hpd = 4; mtmp->data = mdat; mhp = (mdat->mlevel) * 8; /* new hp: same fraction of max as before */ mtmp->mhp = 2 + (hpn * mhp) / hpd; hpn = mtmp->mhpmax; mtmp->mhpmax = 2 + (hpn * mhp) / hpd; mtmp->minvis = (mdat->mlet == 'I') ? 1 : 0; #ifndef NOWORM if (mdat->mlet == 'w' && getwn(mtmp)) initworm(mtmp); /* perhaps we should clear mtmp->mtame here? */ #endif /* NOWORM */ unpmon(mtmp); /* necessary for 'I' and to force pmon */ pmon(mtmp); return (1); } void mnexto(mtmp) /* Make monster mtmp next to you (if * possible) */ struct monst *mtmp; { coord mm; mm = enexto(u.ux, u.uy); mtmp->mx = mm.x; mtmp->my = mm.y; pmon(mtmp); } int ishuman(mtmp) struct monst *mtmp; { return (mtmp->data->mlet == '@'); } void setmangry(mtmp) struct monst *mtmp; { if (!mtmp->mpeaceful) return; if (mtmp->mtame) return; mtmp->mpeaceful = 0; if (ishuman(mtmp)) pline("%s gets angry!", Monnam(mtmp)); } /* * not one hundred procent correct: now a snake may hide under an invisible * object */ int canseemon(mtmp) struct monst *mtmp; { return ((!mtmp->minvis || See_invisible) && (!mtmp->mhide || !o_at(mtmp->mx, mtmp->my)) && cansee(mtmp->mx, mtmp->my)); } bsd-games-2.17/hack/Makefile.bsd0000664000175000017500000000345307767741711015142 0ustar jsm28jsm28# $NetBSD: Makefile,v 1.39 2003/11/16 14:14:18 lukem Exp $ # @(#)Makefile 8.2 (Berkeley) 4/27/95 .include PROG= hack CPPFLAGS+=-I. DPSRCS+=hack.onames.h hack.h SRCS+= alloc.c hack.Decl.c hack.apply.c hack.bones.c hack.c hack.cmd.c \ hack.do.c hack.do_name.c hack.do_wear.c hack.dog.c hack.eat.c \ hack.end.c hack.engrave.c hack.fight.c hack.invent.c hack.ioctl.c \ hack.lev.c hack.main.c hack.makemon.c hack.mhitu.c hack.mklev.c \ hack.mkmaze.c hack.mkobj.c hack.mkshop.c hack.mon.c hack.monst.c \ hack.o_init.c hack.objnam.c hack.options.c hack.pager.c hack.potion.c \ hack.pri.c hack.read.c hack.rip.c hack.rumors.c hack.save.c \ hack.search.c hack.shk.c hack.shknam.c hack.steal.c hack.termcap.c \ hack.timeout.c hack.topl.c hack.track.c hack.trap.c hack.tty.c \ hack.u_init.c hack.unix.c hack.vault.c hack.version.c hack.wield.c \ hack.wizard.c hack.worm.c hack.worn.c hack.zap.c rnd.c MAN= hack.6 DPADD+= ${LIBTERM} ${LIBCOMPAT} LDADD+= -ltermcap HIDEGAME=hidegame SETGIDGAME=yes CLEANFILES+=makedefs makedefs.lo FILES=help hh data FILESDIR=/var/games/hackdir CLEANFILES+=hack.onames.h hack.onames.h: makedefs def.objects.h ${_MKTARGET_CREATE} ./makedefs ${.CURDIR}/def.objects.h > hack.onames.h makedefs: makedefs.lo ${_MKTARGET_LINK} ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} hack.h: hack.onames.h .if !exists(${DESTDIR}${FILESDIR}/perm) afterinstall: clobber .endif clobber: ${_MKMSG_INSTALL} ${DESTDIR}/var/games/hackdir/perm ${INSTALL_FILE} -o games -g games -m 660 /dev/null \ ${DESTDIR}/var/games/hackdir/perm ${_MKMSG_INSTALL} ${DESTDIR}/var/games/hackdir/record ${INSTALL_FILE} -o games -g games -m 660 /dev/null \ ${DESTDIR}/var/games/hackdir/record ${_MKMSG_REMOVE} "${DESTDIR}/var/games/hackdir/bones*" rm -f ${DESTDIR}/var/games/hackdir/bones* .include bsd-games-2.17/hack/hack.fight.c0000664000175000017500000003075307767741711015110 0ustar jsm28jsm28/* $NetBSD: hack.fight.c,v 1.6 2003/04/02 18:36:36 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.fight.c,v 1.6 2003/04/02 18:36:36 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" static boolean far_noise; static long noisetime; /* hitmm returns 0 (miss), 1 (hit), or 2 (kill) */ int hitmm(magr, mdef) struct monst *magr, *mdef; { const struct permonst *pa = magr->data, *pd = mdef->data; int hit; schar tmp; boolean vis; if (strchr("Eauy", pa->mlet)) return (0); if (magr->mfroz) return (0); /* riv05!a3 */ tmp = pd->ac + pa->mlevel; if (mdef->mconf || mdef->mfroz || mdef->msleep) { tmp += 4; if (mdef->msleep) mdef->msleep = 0; } hit = (tmp > rnd(20)); if (hit) mdef->msleep = 0; vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my)); if (vis) { char buf[BUFSZ]; if (mdef->mimic) seemimic(mdef); if (magr->mimic) seemimic(magr); (void) sprintf(buf, "%s %s", Monnam(magr), hit ? "hits" : "misses"); pline("%s %s.", buf, monnam(mdef)); } else { boolean far = (dist(magr->mx, magr->my) > 15); if (far != far_noise || moves - noisetime > 10) { far_noise = far; noisetime = moves; pline("You hear some noises%s.", far ? " in the distance" : ""); } } if (hit) { if (magr->data->mlet == 'c' && !magr->cham) { magr->mhpmax += 3; if (vis) pline("%s is turned to stone!", Monnam(mdef)); else if (mdef->mtame) pline("You have a peculiarly sad feeling for a moment, then it passes."); monstone(mdef); hit = 2; } else if ((mdef->mhp -= d(pa->damn, pa->damd)) < 1) { magr->mhpmax += 1 + rn2(pd->mlevel + 1); if (magr->mtame && magr->mhpmax > 8 * pa->mlevel) { if (pa == &li_dog) magr->data = pa = &dog; else if (pa == &dog) magr->data = pa = &la_dog; } if (vis) pline("%s is killed!", Monnam(mdef)); else if (mdef->mtame) pline("You have a sad feeling for a moment, then it passes."); mondied(mdef); hit = 2; } } return (hit); } /* drop (perhaps) a cadaver and remove monster */ void mondied(mdef) struct monst *mdef; { const struct permonst *pd = mdef->data; if (letter(pd->mlet) && rn2(3)) { (void) mkobj_at(pd->mlet, mdef->mx, mdef->my); if (cansee(mdef->mx, mdef->my)) { unpmon(mdef); atl(mdef->mx, mdef->my, fobj->olet); } stackobj(fobj); } mondead(mdef); } /* drop a rock and remove monster */ void monstone(mdef) struct monst *mdef; { if (strchr(mlarge, mdef->data->mlet)) mksobj_at(ENORMOUS_ROCK, mdef->mx, mdef->my); else mksobj_at(ROCK, mdef->mx, mdef->my); if (cansee(mdef->mx, mdef->my)) { unpmon(mdef); atl(mdef->mx, mdef->my, fobj->olet); } mondead(mdef); } int fightm(mtmp) struct monst *mtmp; { struct monst *mon; for (mon = fmon; mon; mon = mon->nmon) if (mon != mtmp) { if (DIST(mon->mx, mon->my, mtmp->mx, mtmp->my) < 3) if (rn2(4)) return (hitmm(mtmp, mon)); } return (-1); } /* u is hit by sth, but not a monster */ int thitu(tlev, dam, name) int tlev, dam; const char *name; { char buf[BUFSZ]; setan(name, buf); if (u.uac + tlev <= rnd(20)) { if (Blind) pline("It misses."); else pline("You are almost hit by %s!", buf); return (0); } else { if (Blind) pline("You are hit!"); else pline("You are hit by %s!", buf); losehp(dam, name); return (1); } } char mlarge[] = "bCDdegIlmnoPSsTUwY',&"; boolean hmon(mon, obj, thrown) /* return TRUE if mon still alive */ struct monst *mon; struct obj *obj; int thrown; { int tmp; boolean hittxt = FALSE; if (!obj) { tmp = rnd(2); /* attack with bare hands */ if (mon->data->mlet == 'c' && !uarmg) { pline("You hit the cockatrice with your bare hands."); pline("You turn to stone ..."); done_in_by(mon); } } else if (obj->olet == WEAPON_SYM || obj->otyp == PICK_AXE) { if (obj == uwep && (obj->otyp > SPEAR || obj->otyp < BOOMERANG)) tmp = rnd(2); else { if (strchr(mlarge, mon->data->mlet)) { tmp = rnd(objects[obj->otyp].wldam); if (obj->otyp == TWO_HANDED_SWORD) tmp += d(2, 6); else if (obj->otyp == FLAIL) tmp += rnd(4); } else { tmp = rnd(objects[obj->otyp].wsdam); } tmp += obj->spe; if (!thrown && obj == uwep && obj->otyp == BOOMERANG && !rn2(3)) { pline("As you hit %s, the boomerang breaks into splinters.", monnam(mon)); freeinv(obj); setworn((struct obj *) 0, obj->owornmask); obfree(obj, (struct obj *) 0); tmp++; } } if (mon->data->mlet == 'O' && obj->otyp == TWO_HANDED_SWORD && !strcmp(ONAME(obj), "Orcrist")) tmp += rnd(10); } else switch (obj->otyp) { case HEAVY_IRON_BALL: tmp = rnd(25); break; case EXPENSIVE_CAMERA: pline("You succeed in destroying your camera. Congratulations!"); freeinv(obj); if (obj->owornmask) setworn((struct obj *) 0, obj->owornmask); obfree(obj, (struct obj *) 0); return (TRUE); case DEAD_COCKATRICE: pline("You hit %s with the cockatrice corpse.", monnam(mon)); if (mon->data->mlet == 'c') { tmp = 1; hittxt = TRUE; break; } pline("%s is turned to stone!", Monnam(mon)); killed(mon); return (FALSE); case CLOVE_OF_GARLIC: /* no effect against demons */ if (strchr(UNDEAD, mon->data->mlet)) mon->mflee = 1; tmp = 1; break; default: /* non-weapons can damage because of their weight */ /* (but not too much) */ tmp = obj->owt / 10; if (tmp < 1) tmp = 1; else tmp = rnd(tmp); if (tmp > 6) tmp = 6; } /****** NOTE: perhaps obj is undefined!! (if !thrown && BOOMERANG) */ tmp += u.udaminc + dbon(); if (u.uswallow) { if ((tmp -= u.uswldtim) <= 0) { pline("Your arms are no longer able to hit."); return (TRUE); } } if (tmp < 1) tmp = 1; mon->mhp -= tmp; if (mon->mhp < 1) { killed(mon); return (FALSE); } if (mon->mtame && (!mon->mflee || mon->mfleetim)) { mon->mflee = 1; /* Rick Richardson */ mon->mfleetim += 10 * rnd(tmp); } if (!hittxt) { if (thrown) /* this assumes that we cannot throw plural things */ hit(xname(obj) /* or: objects[obj->otyp].oc_name */ , mon, exclam(tmp)); else if (Blind) pline("You hit it."); else pline("You hit %s%s", monnam(mon), exclam(tmp)); } if (u.umconf && !thrown) { if (!Blind) { pline("Your hands stop glowing blue."); if (!mon->mfroz && !mon->msleep) pline("%s appears confused.", Monnam(mon)); } mon->mconf = 1; u.umconf = 0; } return (TRUE); /* mon still alive */ } /* try to attack; return FALSE if monster evaded */ /* u.dx and u.dy must be set */ int attack(mtmp) struct monst *mtmp; { schar tmp; boolean malive = TRUE; const struct permonst *mdat; mdat = mtmp->data; u_wipe_engr(3); /* andrew@orca: prevent unlimited pick-axe * attacks */ if (mdat->mlet == 'L' && !mtmp->mfroz && !mtmp->msleep && !mtmp->mconf && mtmp->mcansee && !rn2(7) && (m_move(mtmp, 0) == 2 /* he died */ || /* he moved: */ mtmp->mx != u.ux + u.dx || mtmp->my != u.uy + u.dy)) return (FALSE); if (mtmp->mimic) { if (!u.ustuck && !mtmp->mflee) u.ustuck = mtmp; switch (levl[u.ux + u.dx][u.uy + u.dy].scrsym) { case '+': pline("The door actually was a Mimic."); break; case '$': pline("The chest was a Mimic!"); break; default: pline("Wait! That's a Mimic!"); } wakeup(mtmp); /* clears mtmp->mimic */ return (TRUE); } wakeup(mtmp); if (mtmp->mhide && mtmp->mundetected) { struct obj *obj; mtmp->mundetected = 0; if ((obj = o_at(mtmp->mx, mtmp->my)) && !Blind) pline("Wait! There's a %s hiding under %s!", mdat->mname, doname(obj)); return (TRUE); } tmp = u.uluck + u.ulevel + mdat->ac + abon(); if (uwep) { if (uwep->olet == WEAPON_SYM || uwep->otyp == PICK_AXE) tmp += uwep->spe; if (uwep->otyp == TWO_HANDED_SWORD) tmp -= 1; else if (uwep->otyp == DAGGER) tmp += 2; else if (uwep->otyp == CRYSKNIFE) tmp += 3; else if (uwep->otyp == SPEAR && strchr("XDne", mdat->mlet)) tmp += 2; } if (mtmp->msleep) { mtmp->msleep = 0; tmp += 2; } if (mtmp->mfroz) { tmp += 4; if (!rn2(10)) mtmp->mfroz = 0; } if (mtmp->mflee) tmp += 2; if (u.utrap) tmp -= 3; /* with a lot of luggage, your agility diminishes */ tmp -= (inv_weight() + 40) / 20; if (tmp <= rnd(20) && !u.uswallow) { if (Blind) pline("You miss it."); else pline("You miss %s.", monnam(mtmp)); } else { /* we hit the monster; be careful: it might die! */ if ((malive = hmon(mtmp, uwep, 0)) == TRUE) { /* monster still alive */ if (!rn2(25) && mtmp->mhp < mtmp->mhpmax / 2) { mtmp->mflee = 1; if (!rn2(3)) mtmp->mfleetim = rnd(100); if (u.ustuck == mtmp && !u.uswallow) u.ustuck = 0; } #ifndef NOWORM if (mtmp->wormno) cutworm(mtmp, u.ux + u.dx, u.uy + u.dy, uwep ? uwep->otyp : 0); #endif /* NOWORM */ } if (mdat->mlet == 'a') { if (rn2(2)) { pline("You are splashed by the blob's acid!"); losehp_m(rnd(6), mtmp); if (!rn2(30)) corrode_armor(); } if (!rn2(6)) corrode_weapon(); } } if (malive && mdat->mlet == 'E' && canseemon(mtmp) && !mtmp->mcan && rn2(3)) { if (mtmp->mcansee) { pline("You are frozen by the floating eye's gaze!"); nomul((u.ulevel > 6 || rn2(4)) ? rn1(20, -21) : -200); } else { pline("The blinded floating eye cannot defend itself."); if (!rn2(500)) if ((int) u.uluck > LUCKMIN) u.uluck--; } } return (TRUE); } bsd-games-2.17/hack/hack.do.c0000664000175000017500000003470110005547567014376 0ustar jsm28jsm28/* $NetBSD: hack.do.c,v 1.7 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.do.c,v 1.7 2004/01/27 20:30:29 jsm Exp $"); #endif /* not lint */ /* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */ #include "hack.h" #include "extern.h" #include #include #include static int drop(struct obj *); int dodrop() { return (drop(getobj("0$#", "drop"))); } static int drop(obj) struct obj *obj; { if (!obj) return (0); if (obj->olet == '$') { /* pseudo object */ long amount = OGOLD(obj); if (amount == 0) pline("You didn't drop any gold pieces."); else { mkgold(amount, u.ux, u.uy); pline("You dropped %ld gold piece%s.", amount, plur(amount)); if (Invisible) newsym(u.ux, u.uy); } free((char *) obj); return (1); } if (obj->owornmask & (W_ARMOR | W_RING)) { pline("You cannot drop something you are wearing."); return (0); } if (obj == uwep) { if (uwep->cursed) { pline("Your weapon is welded to your hand!"); return (0); } setuwep((struct obj *) 0); } pline("You dropped %s.", doname(obj)); dropx(obj); return (1); } /* Called in several places - should not produce texts */ void dropx(obj) struct obj *obj; { freeinv(obj); dropy(obj); } void dropy(obj) struct obj *obj; { if (obj->otyp == CRYSKNIFE) obj->otyp = WORM_TOOTH; obj->ox = u.ux; obj->oy = u.uy; obj->nobj = fobj; fobj = obj; if (Invisible) newsym(u.ux, u.uy); subfrombill(obj); stackobj(obj); } /* drop several things */ int doddrop() { return (ggetobj("drop", drop, 0)); } int dodown() { if (u.ux != xdnstair || u.uy != ydnstair) { pline("You can't go down here."); return (0); } if (u.ustuck) { pline("You are being held, and cannot go down."); return (1); } if (Levitation) { pline("You're floating high above the stairs."); return (0); } goto_level(dlevel + 1, TRUE); return (1); } int doup() { if (u.ux != xupstair || u.uy != yupstair) { pline("You can't go up here."); return (0); } if (u.ustuck) { pline("You are being held, and cannot go up."); return (1); } if (!Levitation && inv_weight() + 5 > 0) { pline("Your load is too heavy to climb the stairs."); return (1); } goto_level(dlevel - 1, TRUE); return (1); } void goto_level(newlevel, at_stairs) int newlevel; boolean at_stairs; { int fd; boolean up = (newlevel < dlevel); if (newlevel <= 0) done("escaped");/* in fact < 0 is impossible */ if (newlevel > MAXLEVEL) newlevel = MAXLEVEL; /* strange ... */ if (newlevel == dlevel) return; /* this can happen */ glo(dlevel); fd = creat(lock, FMASK); if (fd < 0) { /* * This is not quite impossible: e.g., we may have * exceeded our quota. If that is the case then we * cannot leave this level, and cannot save either. * Another possibility is that the directory was not * writable. */ pline("A mysterious force prevents you from going %s.", up ? "up" : "down"); return; } if (Punished) unplacebc(); u.utrap = 0; /* needed in level_tele */ u.ustuck = 0; /* idem */ keepdogs(); seeoff(1); if (u.uswallow) /* idem */ u.uswldtim = u.uswallow = 0; flags.nscrinh = 1; u.ux = FAR; /* hack */ (void) inshop(); /* probably was a trapdoor */ savelev(fd, dlevel); (void) close(fd); dlevel = newlevel; if (maxdlevel < dlevel) maxdlevel = dlevel; glo(dlevel); if (!level_exists[dlevel]) mklev(); else { if ((fd = open(lock, O_RDONLY)) < 0) { pline("Cannot open %s .", lock); pline("Probably someone removed it."); done("tricked"); } getlev(fd, hackpid, dlevel); (void) close(fd); } if (at_stairs) { if (up) { u.ux = xdnstair; u.uy = ydnstair; if (!u.ux) { /* entering a maze from below? */ u.ux = xupstair; /* this will confuse the * player! */ u.uy = yupstair; } if (Punished && !Levitation) { pline("With great effort you climb the stairs."); placebc(1); } } else { u.ux = xupstair; u.uy = yupstair; if (inv_weight() + 5 > 0 || Punished) { pline("You fall down the stairs."); /* %% */ losehp(rnd(3), "fall"); if (Punished) { if (uwep != uball && rn2(3)) { pline("... and are hit by the iron ball."); losehp(rnd(20), "iron ball"); } placebc(1); } selftouch("Falling, you"); } } { struct monst *mtmp = m_at(u.ux, u.uy); if (mtmp) mnexto(mtmp); } } else { /* trapdoor or level_tele */ do { u.ux = rnd(COLNO - 1); u.uy = rn2(ROWNO); } while (levl[u.ux][u.uy].typ != ROOM || m_at(u.ux, u.uy)); if (Punished) { if (uwep != uball && !up /* %% */ && rn2(5)) { pline("The iron ball falls on your head."); losehp(rnd(25), "iron ball"); } placebc(1); } selftouch("Falling, you"); } (void) inshop(); initrack(); losedogs(); { struct monst *mtmp; if ((mtmp = m_at(u.ux, u.uy)) != NULL) mnexto(mtmp); /* riv05!a3 */ } flags.nscrinh = 0; setsee(); seeobjs(); /* make old cadavers disappear - riv05!a3 */ docrt(); pickup(1); read_engr_at(u.ux, u.uy); } int donull() { return (1); /* Do nothing, but let other things happen */ } int dopray() { nomovemsg = "You finished your prayer."; nomul(-3); return (1); } int dothrow() { struct obj *obj; struct monst *mon; int tmp; obj = getobj("#)", "throw"); /* it is also possible to throw food */ /* (or jewels, or iron balls ... ) */ if (!obj || !getdir(1)) /* ask "in what direction?" */ return (0); if (obj->owornmask & (W_ARMOR | W_RING)) { pline("You can't throw something you are wearing."); return (0); } u_wipe_engr(2); if (obj == uwep) { if (obj->cursed) { pline("Your weapon is welded to your hand."); return (1); } if (obj->quan > 1) setuwep(splitobj(obj, 1)); else setuwep((struct obj *) 0); } else if (obj->quan > 1) (void) splitobj(obj, 1); freeinv(obj); if (u.uswallow) { mon = u.ustuck; bhitpos.x = mon->mx; bhitpos.y = mon->my; } else if (u.dz) { if (u.dz < 0) { pline("%s hits the ceiling, then falls back on top of your head.", Doname(obj)); /* note: obj->quan == 1 */ if (obj->olet == POTION_SYM) potionhit(&youmonst, obj); else { if (uarmh) pline("Fortunately, you are wearing a helmet!"); losehp(uarmh ? 1 : rnd((int) (obj->owt)), "falling object"); dropy(obj); } } else { pline("%s hits the floor.", Doname(obj)); if (obj->otyp == EXPENSIVE_CAMERA) { pline("It is shattered in a thousand pieces!"); obfree(obj, Null(obj)); } else if (obj->otyp == EGG) { pline("\"Splash!\""); obfree(obj, Null(obj)); } else if (obj->olet == POTION_SYM) { pline("The flask breaks, and you smell a peculiar odor ..."); potionbreathe(obj); obfree(obj, Null(obj)); } else { dropy(obj); } } return (1); } else if (obj->otyp == BOOMERANG) { mon = boomhit(u.dx, u.dy); if (mon == &youmonst) { /* the thing was caught */ (void) addinv(obj); return (1); } } else { if (obj->otyp == PICK_AXE && shkcatch(obj)) return (1); mon = bhit(u.dx, u.dy, (obj->otyp == ICE_BOX) ? 1 : (!Punished || obj != uball) ? 8 : !u.ustuck ? 5 : 1, obj->olet, (void (*)(struct monst *, struct obj *)) 0, (int (*)(struct obj *, struct obj *)) 0, obj); } if (mon) { /* awake monster if sleeping */ wakeup(mon); if (obj->olet == WEAPON_SYM) { tmp = -1 + u.ulevel + mon->data->ac + abon(); if (obj->otyp < ROCK) { if (!uwep || uwep->otyp != obj->otyp + (BOW - ARROW)) tmp -= 4; else { tmp += uwep->spe; } } else if (obj->otyp == BOOMERANG) tmp += 4; tmp += obj->spe; if (u.uswallow || tmp >= rnd(20)) { if (hmon(mon, obj, 1) == TRUE) { /* mon still alive */ #ifndef NOWORM cutworm(mon, bhitpos.x, bhitpos.y, obj->otyp); #endif /* NOWORM */ } else mon = 0; /* weapons thrown disappear sometimes */ if (obj->otyp < BOOMERANG && rn2(3)) { /* check bill; free */ obfree(obj, (struct obj *) 0); return (1); } } else miss(objects[obj->otyp].oc_name, mon); } else if (obj->otyp == HEAVY_IRON_BALL) { tmp = -1 + u.ulevel + mon->data->ac + abon(); if (!Punished || obj != uball) tmp += 2; if (u.utrap) tmp -= 2; if (u.uswallow || tmp >= rnd(20)) { if (hmon(mon, obj, 1) == FALSE) mon = 0; /* he died */ } else miss("iron ball", mon); } else if (obj->olet == POTION_SYM && u.ulevel > rn2(15)) { potionhit(mon, obj); return (1); } else { if (cansee(bhitpos.x, bhitpos.y)) pline("You miss %s.", monnam(mon)); else pline("You miss it."); if (obj->olet == FOOD_SYM && mon->data->mlet == 'd') if (tamedog(mon, obj)) return (1); if (obj->olet == GEM_SYM && mon->data->mlet == 'u' && !mon->mtame) { if (obj->dknown && objects[obj->otyp].oc_name_known) { if (objects[obj->otyp].g_val > 0) { u.uluck += 5; goto valuable; } else { pline("%s is not interested in your junk.", Monnam(mon)); } } else { /* value unknown to @ */ u.uluck++; valuable: if (u.uluck > LUCKMAX) /* dan@ut-ngp */ u.uluck = LUCKMAX; pline("%s graciously accepts your gift.", Monnam(mon)); mpickobj(mon, obj); rloc(mon); return (1); } } } } /* the code following might become part of dropy() */ if (obj->otyp == CRYSKNIFE) obj->otyp = WORM_TOOTH; obj->ox = bhitpos.x; obj->oy = bhitpos.y; obj->nobj = fobj; fobj = obj; /* prevent him from throwing articles to the exit and escaping */ /* subfrombill(obj); */ stackobj(obj); if (Punished && obj == uball && (bhitpos.x != u.ux || bhitpos.y != u.uy)) { freeobj(uchain); unpobj(uchain); if (u.utrap) { if (u.utraptype == TT_PIT) pline("The ball pulls you out of the pit!"); else { long side = rn2(3) ? LEFT_SIDE : RIGHT_SIDE; pline("The ball pulls you out of the bear trap."); pline("Your %s leg is severely damaged.", (side == LEFT_SIDE) ? "left" : "right"); set_wounded_legs(side, 500 + rn2(1000)); losehp(2, "thrown ball"); } u.utrap = 0; } unsee(); uchain->nobj = fobj; fobj = uchain; u.ux = uchain->ox = bhitpos.x - u.dx; u.uy = uchain->oy = bhitpos.y - u.dy; setsee(); (void) inshop(); } if (cansee(bhitpos.x, bhitpos.y)) prl(bhitpos.x, bhitpos.y); return (1); } /* split obj so that it gets size num */ /* remainder is put in the object structure delivered by this call */ struct obj * splitobj(obj, num) struct obj *obj; int num; { struct obj *otmp; otmp = newobj(0); *otmp = *obj; /* copies whole structure */ otmp->o_id = flags.ident++; otmp->onamelth = 0; obj->quan = num; obj->owt = weight(obj); otmp->quan -= num; otmp->owt = weight(otmp); /* -= obj->owt ? */ obj->nobj = otmp; if (obj->unpaid) splitbill(obj, otmp); return (otmp); } void more_experienced(exp, rexp) int exp, rexp; { u.uexp += exp; u.urexp += 4 * exp + rexp; if (exp) flags.botl = 1; if (u.urexp >= ((pl_character[0] == 'W') ? 1000 : 2000)) flags.beginner = 0; } void set_wounded_legs(side, timex) long side; int timex; { if (!Wounded_legs || (Wounded_legs & TIMEOUT)) Wounded_legs |= side + timex; else Wounded_legs |= side; } void heal_legs() { if (Wounded_legs) { if ((Wounded_legs & BOTH_SIDES) == BOTH_SIDES) pline("Your legs feel somewhat better."); else pline("Your leg feels somewhat better."); Wounded_legs = 0; } } bsd-games-2.17/hack/def.wseg.h0000664000175000017500000000656107767741711014611 0ustar jsm28jsm28/* $NetBSD: def.wseg.h,v 1.5 2003/04/02 18:36:35 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_WSEG_H_ #define _DEF_WSEG_H_ #ifndef NOWORM /* worm structure */ struct wseg { struct wseg *nseg; xchar wx,wy; unsigned wdispl:1; }; #define newseg() (struct wseg *) alloc(sizeof(struct wseg)) #endif /* NOWORM */ #endif /* _DEF_WSEG_H_ */ bsd-games-2.17/hack/hack.track.c0000664000175000017500000000762707767741711015117 0ustar jsm28jsm28/* $NetBSD: hack.track.c,v 1.5 2003/04/02 18:36:41 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.track.c,v 1.5 2003/04/02 18:36:41 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #define UTSZ 50 coord utrack[UTSZ]; int utcnt = 0; int utpnt = 0; void initrack() { utcnt = utpnt = 0; } /* add to track */ void settrack() { if (utcnt < UTSZ) utcnt++; if (utpnt == UTSZ) utpnt = 0; utrack[utpnt].x = u.ux; utrack[utpnt].y = u.uy; utpnt++; } coord * gettrack(x, y) int x, y; { int i, cnt, dist; coord tc; cnt = utcnt; for (i = utpnt - 1; cnt--; i--) { if (i == -1) i = UTSZ - 1; tc = utrack[i]; dist = (x - tc.x) * (x - tc.x) + (y - tc.y) * (y - tc.y); if (dist < 3) return (dist ? &(utrack[i]) : 0); } return (0); } bsd-games-2.17/hack/hack.search.c0000664000175000017500000001475407767741711015257 0ustar jsm28jsm28/* $NetBSD: hack.search.c,v 1.5 2003/04/02 18:36:40 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.search.c,v 1.5 2003/04/02 18:36:40 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" int findit() { /* returns number of things found */ int num; xchar zx, zy; struct trap *ttmp; struct monst *mtmp; xchar lx, hx, ly, hy; if (u.uswallow) return (0); for (lx = u.ux; (num = levl[lx - 1][u.uy].typ) && num != CORR; lx--); for (hx = u.ux; (num = levl[hx + 1][u.uy].typ) && num != CORR; hx++); for (ly = u.uy; (num = levl[u.ux][ly - 1].typ) && num != CORR; ly--); for (hy = u.uy; (num = levl[u.ux][hy + 1].typ) && num != CORR; hy++); num = 0; for (zy = ly; zy <= hy; zy++) for (zx = lx; zx <= hx; zx++) { if (levl[zx][zy].typ == SDOOR) { levl[zx][zy].typ = DOOR; atl(zx, zy, '+'); num++; } else if (levl[zx][zy].typ == SCORR) { levl[zx][zy].typ = CORR; atl(zx, zy, CORR_SYM); num++; } else if ((ttmp = t_at(zx, zy)) != NULL) { if (ttmp->ttyp == PIERC) { (void) makemon(PM_PIERCER, zx, zy); num++; deltrap(ttmp); } else if (!ttmp->tseen) { ttmp->tseen = 1; if (!vism_at(zx, zy)) atl(zx, zy, '^'); num++; } } else if ((mtmp = m_at(zx, zy)) != NULL) if (mtmp->mimic) { seemimic(mtmp); num++; } } return (num); } int dosearch() { xchar x, y; struct trap *trap; struct monst *mtmp; if (u.uswallow) pline("What are you looking for? The exit?"); else for (x = u.ux - 1; x < u.ux + 2; x++) for (y = u.uy - 1; y < u.uy + 2; y++) if (x != u.ux || y != u.uy) { if (levl[x][y].typ == SDOOR) { if (rn2(7)) continue; levl[x][y].typ = DOOR; levl[x][y].seen = 0; /* force prl */ prl(x, y); nomul(0); } else if (levl[x][y].typ == SCORR) { if (rn2(7)) continue; levl[x][y].typ = CORR; levl[x][y].seen = 0; /* force prl */ prl(x, y); nomul(0); } else { /* * Be careful not to find * anything in an SCORR or * SDOOR */ if ((mtmp = m_at(x, y)) != NULL) if (mtmp->mimic) { seemimic(mtmp); pline("You find a mimic."); return (1); } for (trap = ftrap; trap; trap = trap->ntrap) if (trap->tx == x && trap->ty == y && !trap->tseen && !rn2(8)) { nomul(0); pline("You find a%s.", traps[trap->ttyp]); if (trap->ttyp == PIERC) { deltrap(trap); (void) makemon(PM_PIERCER, x, y); return (1); } trap->tseen = 1; if (!vism_at(x, y)) atl(x, y, '^'); } } } return (1); } int doidtrap() { struct trap *trap; int x, y; if (!getdir(1)) return (0); x = u.ux + u.dx; y = u.uy + u.dy; for (trap = ftrap; trap; trap = trap->ntrap) if (trap->tx == x && trap->ty == y && trap->tseen) { if (u.dz) if ((u.dz < 0) != (!xdnstair && trap->ttyp == TRAPDOOR)) continue; pline("That is a%s.", traps[trap->ttyp]); return (0); } pline("I can't see a trap there."); return (0); } void wakeup(mtmp) struct monst *mtmp; { mtmp->msleep = 0; setmangry(mtmp); if (mtmp->mimic) seemimic(mtmp); } /* NOTE: we must check if(mtmp->mimic) before calling this routine */ void seemimic(mtmp) struct monst *mtmp; { mtmp->mimic = 0; mtmp->mappearance = 0; unpmon(mtmp); pmon(mtmp); } bsd-games-2.17/hack/hack.end.c0000664000175000017500000004770207767741711014557 0ustar jsm28jsm28/* $NetBSD: hack.end.c,v 1.6 2003/04/02 18:36:36 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.end.c,v 1.6 2003/04/02 18:36:36 jsm Exp $"); #endif /* not lint */ #include #include #include #include "hack.h" #include "extern.h" #define Sprintf (void) sprintf xchar maxdlevel = 1; int dodone() { done1(0); return 0; } /*ARGSUSED*/ void done1(n) int n __attribute__((__unused__)); { (void) signal(SIGINT, SIG_IGN); pline("Really quit?"); if (readchar() != 'y') { (void) signal(SIGINT, done1); clrlin(); (void) fflush(stdout); if (multi > 0) nomul(0); return; } done("quit"); /* NOTREACHED */ } int done_stopprint; int done_hup; /*ARGSUSED*/ void done_intr(n) int n __attribute__((__unused__)); { done_stopprint++; (void) signal(SIGINT, SIG_IGN); (void) signal(SIGQUIT, SIG_IGN); } void done_hangup(n) int n; { done_hup++; (void) signal(SIGHUP, SIG_IGN); done_intr(n); } void done_in_by(mtmp) struct monst *mtmp; { static char buf[BUFSZ]; pline("You die ..."); if (mtmp->data->mlet == ' ') { Sprintf(buf, "the ghost of %s", (char *) mtmp->mextra); killer = buf; } else if (mtmp->mnamelth) { Sprintf(buf, "%s called %s", mtmp->data->mname, NAME(mtmp)); killer = buf; } else if (mtmp->minvis) { Sprintf(buf, "invisible %s", mtmp->data->mname); killer = buf; } else killer = mtmp->data->mname; done("died"); } /* * called with arg "died", "drowned", "escaped", "quit", "choked", * "panicked", "burned", "starved" or "tricked" */ /* Be careful not to call panic from here! */ void done(st1) const char *st1; { #ifdef WIZARD if (wizard && *st1 == 'd') { u.uswldtim = 0; if (u.uhpmax < 0) u.uhpmax = 100; /* arbitrary */ u.uhp = u.uhpmax; pline("For some reason you are still alive."); flags.move = 0; if (multi > 0) multi = 0; else multi = -1; flags.botl = 1; return; } #endif /* WIZARD */ (void) signal(SIGINT, done_intr); (void) signal(SIGQUIT, done_intr); (void) signal(SIGHUP, done_hangup); if (*st1 == 'q' && u.uhp < 1) { st1 = "died"; killer = "quit while already on Charon's boat"; } if (*st1 == 's') killer = "starvation"; else if (*st1 == 'd' && st1[1] == 'r') killer = "drowning"; else if (*st1 == 'p') killer = "panic"; else if (*st1 == 't') killer = "trickery"; else if (!strchr("bcd", *st1)) killer = st1; paybill(); clearlocks(); if (flags.toplin == 1) more(); if (strchr("bcds", *st1)) { #ifdef WIZARD if (!wizard) #endif /* WIZARD */ savebones(); if (!flags.notombstone) outrip(); } if (*st1 == 'c') killer = st1; /* after outrip() */ settty((char *) 0); /* does a clear_screen() */ if (!done_stopprint) printf("Goodbye %s %s...\n\n", pl_character, plname); { long int tmp; tmp = u.ugold - u.ugold0; if (tmp < 0) tmp = 0; if (*st1 == 'd' || *st1 == 'b') tmp -= tmp / 10; u.urexp += tmp; u.urexp += 50 * maxdlevel; if (maxdlevel > 20) u.urexp += 1000 * ((maxdlevel > 30) ? 10 : maxdlevel - 20); } if (*st1 == 'e') { struct monst *mtmp; struct obj *otmp; int i; unsigned worthlessct = 0; boolean has_amulet = FALSE; killer = st1; keepdogs(); mtmp = mydogs; if (mtmp) { if (!done_stopprint) printf("You"); while (mtmp) { if (!done_stopprint) printf(" and %s", monnam(mtmp)); if (mtmp->mtame) u.urexp += mtmp->mhp; mtmp = mtmp->nmon; } if (!done_stopprint) printf("\nescaped from the dungeon with %ld points,\n", u.urexp); } else if (!done_stopprint) printf("You escaped from the dungeon with %ld points,\n", u.urexp); for (otmp = invent; otmp; otmp = otmp->nobj) { if (otmp->olet == GEM_SYM) { objects[otmp->otyp].oc_name_known = 1; i = otmp->quan * objects[otmp->otyp].g_val; if (i == 0) { worthlessct += otmp->quan; continue; } u.urexp += i; if (!done_stopprint) printf("\t%s (worth %d Zorkmids),\n", doname(otmp), i); } else if (otmp->olet == AMULET_SYM) { otmp->known = 1; i = (otmp->spe < 0) ? 2 : 5000; u.urexp += i; if (!done_stopprint) printf("\t%s (worth %d Zorkmids),\n", doname(otmp), i); if (otmp->spe >= 0) { has_amulet = TRUE; killer = "escaped (with amulet)"; } } } if (worthlessct) if (!done_stopprint) printf("\t%u worthless piece%s of coloured glass,\n", worthlessct, plur(worthlessct)); if (has_amulet) u.urexp *= 2; } else if (!done_stopprint) printf("You %s on dungeon level %d with %ld points,\n", st1, dlevel, u.urexp); if (!done_stopprint) printf("and %ld piece%s of gold, after %ld move%s.\n", u.ugold, plur(u.ugold), moves, plur(moves)); if (!done_stopprint) printf("You were level %u with a maximum of %d hit points when you %s.\n", u.ulevel, u.uhpmax, st1); if (*st1 == 'e' && !done_stopprint) { getret(); /* all those pieces of coloured glass ... */ cls(); } #ifdef WIZARD if (!wizard) #endif /* WIZARD */ topten(); if (done_stopprint) printf("\n\n"); exit(0); } #define newttentry() (struct toptenentry *) alloc(sizeof(struct toptenentry)) #define NAMSZ 8 #define DTHSZ 40 #define PERSMAX 1 #define POINTSMIN 1 /* must be > 0 */ #define ENTRYMAX 100 /* must be >= 10 */ #define PERS_IS_UID /* delete for PERSMAX per name; now per uid */ struct toptenentry { struct toptenentry *tt_next; long int points; int level, maxlvl, hp, maxhp; int uid; char plchar; char sex; char name[NAMSZ + 1]; char death[DTHSZ + 1]; char date[7];/* yymmdd */ } *tt_head; void topten() { int uid = getuid(); int rank, rank0 = -1, rank1 = 0; int occ_cnt = PERSMAX; struct toptenentry *t0, *t1, *tprev; const char *recfile = RECORD; const char *reclock = "record_lock"; int sleepct = 300; FILE *rfile; int flg = 0; #define HUP if(!done_hup) while (link(recfile, reclock) == -1) { HUP perror(reclock); if (!sleepct--) { HUP puts("I give up. Sorry."); HUP puts("Perhaps there is an old record_lock around?"); return; } HUP printf("Waiting for access to record file. (%d)\n", sleepct); HUP(void) fflush(stdout); sleep(1); } if (!(rfile = fopen(recfile, "r"))) { HUP puts("Cannot open record file!"); goto unlock; } HUP(void) putchar('\n'); /* create a new 'topten' entry */ t0 = newttentry(); t0->level = dlevel; t0->maxlvl = maxdlevel; t0->hp = u.uhp; t0->maxhp = u.uhpmax; t0->points = u.urexp; t0->plchar = pl_character[0]; t0->sex = (flags.female ? 'F' : 'M'); t0->uid = uid; (void) strncpy(t0->name, plname, NAMSZ); (t0->name)[NAMSZ] = 0; (void) strncpy(t0->death, killer, DTHSZ); (t0->death)[DTHSZ] = 0; (void) strcpy(t0->date, getdate()); /* assure minimum number of points */ if (t0->points < POINTSMIN) t0->points = 0; t1 = tt_head = newttentry(); tprev = 0; /* rank0: -1 undefined, 0 not_on_list, n n_th on list */ for (rank = 1;;) { if (fscanf(rfile, "%6s %d %d %d %d %d %ld %c%c %[^,],%[^\n]", t1->date, &t1->uid, &t1->level, &t1->maxlvl, &t1->hp, &t1->maxhp, &t1->points, &t1->plchar, &t1->sex, t1->name, t1->death) != 11 || t1->points < POINTSMIN) t1->points = 0; if (rank0 < 0 && t1->points < t0->points) { rank0 = rank++; if (tprev == 0) tt_head = t0; else tprev->tt_next = t0; t0->tt_next = t1; occ_cnt--; flg++; /* ask for a rewrite */ } else tprev = t1; if (t1->points == 0) break; if ( #ifdef PERS_IS_UID t1->uid == t0->uid && #else strncmp(t1->name, t0->name, NAMSZ) == 0 && #endif /* PERS_IS_UID */ t1->plchar == t0->plchar && --occ_cnt <= 0) { if (rank0 < 0) { rank0 = 0; rank1 = rank; HUP printf("You didn't beat your previous score of %ld points.\n\n", t1->points); } if (occ_cnt < 0) { flg++; continue; } } if (rank <= ENTRYMAX) { t1 = t1->tt_next = newttentry(); rank++; } if (rank > ENTRYMAX) { t1->points = 0; break; } } if (flg) { /* rewrite record file */ (void) fclose(rfile); if (!(rfile = fopen(recfile, "w"))) { HUP puts("Cannot write record file\n"); goto unlock; } if (!done_stopprint) if (rank0 > 0) { if (rank0 <= 10) puts("You made the top ten list!\n"); else printf("You reached the %d%s place on the top %d list.\n\n", rank0, ordin(rank0), ENTRYMAX); } } if (rank0 == 0) rank0 = rank1; if (rank0 <= 0) rank0 = rank; if (!done_stopprint) outheader(); t1 = tt_head; for (rank = 1; t1->points != 0; rank++, t1 = t1->tt_next) { if (flg) fprintf(rfile, "%6s %d %d %d %d %d %ld %c%c %s,%s\n", t1->date, t1->uid, t1->level, t1->maxlvl, t1->hp, t1->maxhp, t1->points, t1->plchar, t1->sex, t1->name, t1->death); if (done_stopprint) continue; if (rank > (int)flags.end_top && (rank < rank0 - (int)flags.end_around || rank > rank0 + (int)flags.end_around) && (!flags.end_own || #ifdef PERS_IS_UID t1->uid != t0->uid)) #else strncmp(t1->name, t0->name, NAMSZ))) #endif /* PERS_IS_UID */ continue; if (rank == rank0 - (int)flags.end_around && rank0 > (int)(flags.end_top + flags.end_around + 1) && !flags.end_own) (void) putchar('\n'); if (rank != rank0) (void) outentry(rank, t1, 0); else if (!rank1) (void) outentry(rank, t1, 1); else { int t0lth = outentry(0, t0, -1); int t1lth = outentry(rank, t1, t0lth); if (t1lth > t0lth) t0lth = t1lth; (void) outentry(0, t0, t0lth); } } if (rank0 >= rank) if (!done_stopprint) (void) outentry(0, t0, 1); (void) fclose(rfile); unlock: (void) unlink(reclock); } void outheader() { char linebuf[BUFSZ]; char *bp; (void) strcpy(linebuf, "Number Points Name"); bp = eos(linebuf); while (bp < linebuf + COLNO - 9) *bp++ = ' '; (void) strcpy(bp, "Hp [max]"); puts(linebuf); } /* so>0: standout line; so=0: ordinary line; so<0: no output, return lth */ int outentry(int rank, struct toptenentry *t1, int so) { boolean quit = FALSE, killed = FALSE, starv = FALSE; char linebuf[BUFSZ]; linebuf[0] = 0; if (rank) Sprintf(eos(linebuf), "%3d", rank); else Sprintf(eos(linebuf), " "); Sprintf(eos(linebuf), " %6ld %8s", t1->points, t1->name); if (t1->plchar == 'X') Sprintf(eos(linebuf), " "); else Sprintf(eos(linebuf), "-%c ", t1->plchar); if (!strncmp("escaped", t1->death, 7)) { if (!strcmp(" (with amulet)", t1->death + 7)) Sprintf(eos(linebuf), "escaped the dungeon with amulet"); else Sprintf(eos(linebuf), "escaped the dungeon [max level %d]", t1->maxlvl); } else { if (!strncmp(t1->death, "quit", 4)) { quit = TRUE; if (t1->maxhp < 3 * t1->hp && t1->maxlvl < 4) Sprintf(eos(linebuf), "cravenly gave up"); else Sprintf(eos(linebuf), "quit"); } else if (!strcmp(t1->death, "choked")) Sprintf(eos(linebuf), "choked on %s food", (t1->sex == 'F') ? "her" : "his"); else if (!strncmp(t1->death, "starv", 5)) Sprintf(eos(linebuf), "starved to death"), starv = TRUE; else Sprintf(eos(linebuf), "was killed"), killed = TRUE; Sprintf(eos(linebuf), " on%s level %d", (killed || starv) ? "" : " dungeon", t1->level); if (t1->maxlvl != t1->level) Sprintf(eos(linebuf), " [max %d]", t1->maxlvl); if (quit && t1->death[4]) Sprintf(eos(linebuf), t1->death + 4); } if (killed) Sprintf(eos(linebuf), " by %s%s", (!strncmp(t1->death, "trick", 5) || !strncmp(t1->death, "the ", 4)) ? "" : strchr(vowels, *t1->death) ? "an " : "a ", t1->death); Sprintf(eos(linebuf), "."); if (t1->maxhp) { char *bp = eos(linebuf); char hpbuf[10]; int hppos; Sprintf(hpbuf, (t1->hp > 0) ? itoa(t1->hp) : "-"); hppos = COLNO - 7 - strlen(hpbuf); if (bp <= linebuf + hppos) { while (bp < linebuf + hppos) *bp++ = ' '; (void) strcpy(bp, hpbuf); Sprintf(eos(bp), " [%d]", t1->maxhp); } } if (so == 0) puts(linebuf); else if (so > 0) { char *bp = eos(linebuf); if (so >= COLNO) so = COLNO - 1; while (bp < linebuf + so) *bp++ = ' '; *bp = 0; standoutbeg(); fputs(linebuf, stdout); standoutend(); (void) putchar('\n'); } return (strlen(linebuf)); } char * itoa(a) int a; { static char buf[12]; Sprintf(buf, "%d", a); return (buf); } const char * ordin(n) int n; { int d = n % 10; return ((d == 0 || d > 3 || n / 10 == 1) ? "th" : (d == 1) ? "st" : (d == 2) ? "nd" : "rd"); } void clearlocks() { int x; (void) signal(SIGHUP, SIG_IGN); for (x = maxdlevel; x >= 0; x--) { glo(x); (void) unlink(lock); /* not all levels need be present */ } } #ifdef NOSAVEONHANGUP /*ARGSUSED*/ void hangup(n) int n; { (void) signal(SIGINT, SIG_IGN); clearlocks(); exit(1); } #endif /* NOSAVEONHANGUP */ char * eos(s) char *s; { while (*s) s++; return (s); } /* it is the callers responsibility to check that there is room for c */ void charcat(s, c) char *s, c; { while (*s) s++; *s++ = c; *s = 0; } /* * Called with args from main if argc >= 0. In this case, list scores as * requested. Otherwise, find scores for the current player (and list them * if argc == -1). */ void prscore(argc, argv) int argc; char **argv; { char **players = NULL; int playerct; int rank; struct toptenentry *t1, *t2; const char *recfile = RECORD; FILE *rfile; int flg = 0; int i; #ifdef nonsense long total_score = 0L; char totchars[10]; int totcharct = 0; #endif /* nonsense */ int outflg = (argc >= -1); #ifdef PERS_IS_UID int uid = -1; #else char *player0; #endif /* PERS_IS_UID */ if (!(rfile = fopen(recfile, "r"))) { puts("Cannot open record file!"); return; } if (argc > 1 && !strncmp(argv[1], "-s", 2)) { if (!argv[1][2]) { argc--; argv++; } else if (!argv[1][3] && strchr("CFKSTWX", argv[1][2])) { argv[1]++; argv[1][0] = '-'; } else argv[1] += 2; } if (argc <= 1) { #ifdef PERS_IS_UID uid = getuid(); playerct = 0; #else player0 = plname; if (!*player0) player0 = "hackplayer"; playerct = 1; players = &player0; #endif /* PERS_IS_UID */ } else { playerct = --argc; players = ++argv; } if (outflg) putchar('\n'); t1 = tt_head = newttentry(); for (rank = 1;; rank++) { if (fscanf(rfile, "%6s %d %d %d %d %d %ld %c%c %[^,],%[^\n]", t1->date, &t1->uid, &t1->level, &t1->maxlvl, &t1->hp, &t1->maxhp, &t1->points, &t1->plchar, &t1->sex, t1->name, t1->death) != 11) t1->points = 0; if (t1->points == 0) break; #ifdef PERS_IS_UID if (!playerct && t1->uid == uid) flg++; else #endif /* PERS_IS_UID */ for (i = 0; i < playerct; i++) { if (strcmp(players[i], "all") == 0 || strncmp(t1->name, players[i], NAMSZ) == 0 || (players[i][0] == '-' && players[i][1] == t1->plchar && players[i][2] == 0) || (digit(players[i][0]) && rank <= atoi(players[i]))) flg++; } t1 = t1->tt_next = newttentry(); } (void) fclose(rfile); if (!flg) { if (outflg) { printf("Cannot find any entries for "); if (playerct < 1) printf("you.\n"); else { if (playerct > 1) printf("any of "); for (i = 0; i < playerct; i++) printf("%s%s", players[i], (i < playerct - 1) ? ", " : ".\n"); printf("Call is: %s -s [playernames]\n", hname); } } return; } if (outflg) outheader(); t1 = tt_head; for (rank = 1; t1->points != 0; rank++, t1 = t2) { t2 = t1->tt_next; #ifdef PERS_IS_UID if (!playerct && t1->uid == uid) goto outwithit; else #endif /* PERS_IS_UID */ for (i = 0; i < playerct; i++) { if (strcmp(players[i], "all") == 0 || strncmp(t1->name, players[i], NAMSZ) == 0 || (players[i][0] == '-' && players[i][1] == t1->plchar && players[i][2] == 0) || (digit(players[i][0]) && rank <= atoi(players[i]))) { outwithit: if (outflg) (void) outentry(rank, t1, 0); #ifdef nonsense total_score += t1->points; if (totcharct < sizeof(totchars) - 1) totchars[totcharct++] = t1->plchar; #endif /* nonsense */ break; } } free((char *) t1); } #ifdef nonsense totchars[totcharct] = 0; /* * We would like to determine whether he is experienced. However, the * information collected here only tells about the scores/roles that * got into the topten (top 100?). We should maintain a .hacklog or * something in his home directory. */ flags.beginner = (total_score < 6000); for (i = 0; i < 6; i++) if (!strchr(totchars, "CFKSTWX"[i])) { flags.beginner = 1; if (!pl_character[0]) pl_character[0] = "CFKSTWX"[i]; break; } #endif /* nonsense */ } bsd-games-2.17/hack/hack.steal.c0000664000175000017500000002013507767741711015110 0ustar jsm28jsm28/* $NetBSD: hack.steal.c,v 1.5 2003/04/02 18:36:40 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.steal.c,v 1.5 2003/04/02 18:36:40 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" long /* actually returns something that fits in an * int */ somegold() { return ((u.ugold < 100) ? u.ugold : (u.ugold > 10000) ? rnd(10000) : rnd((int) u.ugold)); } void stealgold(mtmp) struct monst *mtmp; { struct gold *gold = g_at(u.ux, u.uy); long tmp; if (gold && (!u.ugold || gold->amount > u.ugold || !rn2(5))) { mtmp->mgold += gold->amount; freegold(gold); if (Invisible) newsym(u.ux, u.uy); pline("%s quickly snatches some gold from between your feet!", Monnam(mtmp)); if (!u.ugold || !rn2(5)) { rloc(mtmp); mtmp->mflee = 1; } } else if (u.ugold) { u.ugold -= (tmp = somegold()); pline("Your purse feels lighter."); mtmp->mgold += tmp; rloc(mtmp); mtmp->mflee = 1; flags.botl = 1; } } /* steal armor after he finishes taking it off */ unsigned stealoid; /* object to be stolen */ unsigned stealmid; /* monster doing the stealing */ int stealarm() { struct monst *mtmp; struct obj *otmp; for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp->o_id == stealoid) { for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp->m_id == stealmid) { if (dist(mtmp->mx, mtmp->my) < 3) { freeinv(otmp); pline("%s steals %s!", Monnam(mtmp), doname(otmp)); mpickobj(mtmp, otmp); mtmp->mflee = 1; rloc(mtmp); } break; } break; } stealoid = 0; return 0; } /* returns 1 when something was stolen */ /* (or at least, when N should flee now) */ /* avoid stealing the object stealoid */ int steal(mtmp) struct monst *mtmp; { struct obj *otmp; int tmp; int named = 0; if (!invent) { if (Blind) pline("Somebody tries to rob you, but finds nothing to steal."); else pline("%s tries to rob you, but she finds nothing to steal!", Monnam(mtmp)); return (1); /* let her flee */ } tmp = 0; for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp != uarm2) tmp += ((otmp->owornmask & (W_ARMOR | W_RING)) ? 5 : 1); tmp = rn2(tmp); for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp != uarm2) if ((tmp -= ((otmp->owornmask & (W_ARMOR | W_RING)) ? 5 : 1)) < 0) break; if (!otmp) { impossible("Steal fails!"); return (0); } if (otmp->o_id == stealoid) return (0); if ((otmp->owornmask & (W_ARMOR | W_RING))) { switch (otmp->olet) { case RING_SYM: ringoff(otmp); break; case ARMOR_SYM: if (multi < 0 || otmp == uarms) { setworn((struct obj *) 0, otmp->owornmask & W_ARMOR); break; } { int curssv = otmp->cursed; otmp->cursed = 0; stop_occupation(); pline("%s seduces you and %s off your %s.", Amonnam(mtmp, Blind ? "gentle" : "beautiful"), otmp->cursed ? "helps you to take" : "you start taking", (otmp == uarmg) ? "gloves" : (otmp == uarmh) ? "helmet" : "armor"); named++; (void) armoroff(otmp); otmp->cursed = curssv; if (multi < 0) { /* multi = 0; nomovemsg = 0; afternmv = 0; */ stealoid = otmp->o_id; stealmid = mtmp->m_id; afternmv = stealarm; return (0); } break; } default: impossible("Tried to steal a strange worn thing."); } } else if (otmp == uwep) setuwep((struct obj *) 0); if (otmp->olet == CHAIN_SYM) { impossible("How come you are carrying that chain?"); } if (Punished && otmp == uball) { Punished = 0; freeobj(uchain); free((char *) uchain); uchain = (struct obj *) 0; uball->spe = 0; uball = (struct obj *) 0; /* superfluous */ } freeinv(otmp); pline("%s stole %s.", named ? "She" : Monnam(mtmp), doname(otmp)); mpickobj(mtmp, otmp); return ((multi < 0) ? 0 : 1); } void mpickobj(mtmp, otmp) struct monst *mtmp; struct obj *otmp; { otmp->nobj = mtmp->minvent; mtmp->minvent = otmp; } int stealamulet(mtmp) struct monst *mtmp; { struct obj *otmp; for (otmp = invent; otmp; otmp = otmp->nobj) { if (otmp->olet == AMULET_SYM) { /* might be an imitation one */ if (otmp == uwep) setuwep((struct obj *) 0); freeinv(otmp); mpickobj(mtmp, otmp); pline("%s stole %s!", Monnam(mtmp), doname(otmp)); return (1); } } return (0); } /* release the objects the killed animal has stolen */ void relobj(mtmp, show) struct monst *mtmp; int show; { struct obj *otmp, *otmp2; for (otmp = mtmp->minvent; otmp; otmp = otmp2) { otmp->ox = mtmp->mx; otmp->oy = mtmp->my; otmp2 = otmp->nobj; otmp->nobj = fobj; fobj = otmp; stackobj(fobj); if (show & cansee(mtmp->mx, mtmp->my)) atl(otmp->ox, otmp->oy, otmp->olet); } mtmp->minvent = (struct obj *) 0; if (mtmp->mgold || mtmp->data->mlet == 'L') { long tmp; tmp = (mtmp->mgold > 10000) ? 10000 : mtmp->mgold; mkgold((long) (tmp + d(dlevel, 30)), mtmp->mx, mtmp->my); if (show & cansee(mtmp->mx, mtmp->my)) atl(mtmp->mx, mtmp->my, '$'); } } bsd-games-2.17/hack/hack.ioctl.c0000664000175000017500000001017607767741711015116 0ustar jsm28jsm28/* $NetBSD: hack.ioctl.c,v 1.7 2003/04/02 18:36:37 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.ioctl.c,v 1.7 2003/04/02 18:36:37 jsm Exp $"); #endif /* not lint */ /* * This cannot be part of hack.tty.c (as it was earlier) since on some * systems (e.g. MUNIX) the include files and define the * same constants, and the C preprocessor complains. */ #include #include "hack.h" #include "extern.h" struct termios termios; void getioctls() { (void) tcgetattr(fileno(stdin), &termios); } void setioctls() { (void) tcsetattr(fileno(stdin), TCSADRAIN, &termios); } #ifdef SUSPEND /* implies BSD */ #include int dosuspend() { #ifdef SIGTSTP if (signal(SIGTSTP, SIG_IGN) == SIG_DFL) { settty((char *) 0); (void) signal(SIGTSTP, SIG_DFL); (void) kill(0, SIGTSTP); gettty(); setftty(); docrt(); } else { pline("I don't think your shell has job control."); } #else /* SIGTSTP */ pline("Sorry, it seems we have no SIGTSTP here. Try ! or S."); #endif /* SIGTSTP */ return (0); } #endif /* SUSPEND */ bsd-games-2.17/hack/date.h0000664000175000017500000000623207767741711014017 0ustar jsm28jsm28/* $NetBSD: date.h,v 1.5 2003/04/02 18:36:33 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ const char datestring[] = "Tue Jul 23 1985"; bsd-games-2.17/hack/def.func_tab.h0000664000175000017500000000663710005547567015421 0ustar jsm28jsm28/* $NetBSD: def.func_tab.h,v 1.7 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_FUNC_TAB_H_ #define _DEF_FUNC_TAB_H_ struct func_tab { char f_char; int (*f_funct)(void); }; extern const struct func_tab cmdlist[]; struct ext_func_tab { const char *ef_txt; int (*ef_funct)(void); }; extern const struct ext_func_tab extcmdlist[]; #endif /* _DEF_FUNC_TAB_H_ */ bsd-games-2.17/hack/COPYRIGHT-JF0000664000175000017500000000277107767741711014525 0ustar jsm28jsm28$NetBSD: COPYRIGHT-JF,v 1.1 2003/04/02 18:36:33 jsm Exp $ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ bsd-games-2.17/hack/hack.do_wear.c0000664000175000017500000002540207767741711015422 0ustar jsm28jsm28/* $NetBSD: hack.do_wear.c,v 1.5 2003/04/02 18:36:36 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.do_wear.c,v 1.5 2003/04/02 18:36:36 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" void off_msg(otmp) struct obj *otmp; { pline("You were wearing %s.", doname(otmp)); } int doremarm() { struct obj *otmp; if (!uarm && !uarmh && !uarms && !uarmg) { pline("Not wearing any armor."); return (0); } otmp = (!uarmh && !uarms && !uarmg) ? uarm : (!uarms && !uarm && !uarmg) ? uarmh : (!uarmh && !uarm && !uarmg) ? uarms : (!uarmh && !uarm && !uarms) ? uarmg : getobj("[", "take off"); if (!otmp) return (0); if (!(otmp->owornmask & (W_ARMOR - W_ARM2))) { pline("You can't take that off."); return (0); } if (otmp == uarmg && uwep && uwep->cursed) { /* myers@uwmacc */ pline("You seem not able to take off the gloves while holding your weapon."); return (0); } (void) armoroff(otmp); return (1); } int doremring() { if (!uleft && !uright) { pline("Not wearing any ring."); return (0); } if (!uleft) return (dorr(uright)); if (!uright) return (dorr(uleft)); if (uleft && uright) while (1) { char answer; pline("What ring, Right or Left? [ rl?]"); if (strchr(quitchars, (answer = readchar()))) return (0); switch (answer) { case 'l': case 'L': return (dorr(uleft)); case 'r': case 'R': return (dorr(uright)); case '?': (void) doprring(); /* might look at morc here %% */ } } /* NOTREACHED */ return (0); } int dorr(otmp) struct obj *otmp; { if (cursed(otmp)) return (0); ringoff(otmp); off_msg(otmp); return (1); } int cursed(otmp) struct obj *otmp; { if (otmp->cursed) { pline("You can't. It appears to be cursed."); return (1); } return (0); } int armoroff(otmp) struct obj *otmp; { int delay = -objects[otmp->otyp].oc_delay; if (cursed(otmp)) return (0); setworn((struct obj *) 0, otmp->owornmask & W_ARMOR); if (delay) { nomul(delay); switch (otmp->otyp) { case HELMET: nomovemsg = "You finished taking off your helmet."; break; case PAIR_OF_GLOVES: nomovemsg = "You finished taking off your gloves"; break; default: nomovemsg = "You finished taking off your suit."; } } else { off_msg(otmp); } return (1); } int doweararm() { struct obj *otmp; int delay; int err = 0; long mask = 0; otmp = getobj("[", "wear"); if (!otmp) return (0); if (otmp->owornmask & W_ARMOR) { pline("You are already wearing that!"); return (0); } if (otmp->otyp == HELMET) { if (uarmh) { pline("You are already wearing a helmet."); err++; } else mask = W_ARMH; } else if (otmp->otyp == SHIELD) { if (uarms) pline("You are already wearing a shield."), err++; if (uwep && uwep->otyp == TWO_HANDED_SWORD) pline("You cannot wear a shield and wield a two-handed sword."), err++; if (!err) mask = W_ARMS; } else if (otmp->otyp == PAIR_OF_GLOVES) { if (uarmg) { pline("You are already wearing gloves."); err++; } else if (uwep && uwep->cursed) { pline("You cannot wear gloves over your weapon."); err++; } else mask = W_ARMG; } else { if (uarm) { if (otmp->otyp != ELVEN_CLOAK || uarm2) { pline("You are already wearing some armor."); err++; } } if (!err) mask = W_ARM; } if (otmp == uwep && uwep->cursed) { if (!err++) pline("%s is welded to your hand.", Doname(uwep)); } if (err) return (0); setworn(otmp, mask); if (otmp == uwep) setuwep((struct obj *) 0); delay = -objects[otmp->otyp].oc_delay; if (delay) { nomul(delay); nomovemsg = "You finished your dressing manoeuvre."; } otmp->known = 1; return (1); } int dowearring() { struct obj *otmp; long mask = 0; long oldprop; if (uleft && uright) { pline("There are no more ring-fingers to fill."); return (0); } otmp = getobj("=", "wear"); if (!otmp) return (0); if (otmp->owornmask & W_RING) { pline("You are already wearing that!"); return (0); } if (otmp == uleft || otmp == uright) { pline("You are already wearing that."); return (0); } if (otmp == uwep && uwep->cursed) { pline("%s is welded to your hand.", Doname(uwep)); return (0); } if (uleft) mask = RIGHT_RING; else if (uright) mask = LEFT_RING; else do { char answer; pline("What ring-finger, Right or Left? "); if (strchr(quitchars, (answer = readchar()))) return (0); switch (answer) { case 'l': case 'L': mask = LEFT_RING; break; case 'r': case 'R': mask = RIGHT_RING; break; } } while (!mask); setworn(otmp, mask); if (otmp == uwep) setuwep((struct obj *) 0); oldprop = u.uprops[PROP(otmp->otyp)].p_flgs; u.uprops[PROP(otmp->otyp)].p_flgs |= mask; switch (otmp->otyp) { case RIN_LEVITATION: if (!oldprop) float_up(); break; case RIN_PROTECTION_FROM_SHAPE_CHANGERS: rescham(); break; case RIN_GAIN_STRENGTH: u.ustr += otmp->spe; u.ustrmax += otmp->spe; if (u.ustr > 118) u.ustr = 118; if (u.ustrmax > 118) u.ustrmax = 118; flags.botl = 1; break; case RIN_INCREASE_DAMAGE: u.udaminc += otmp->spe; break; } prinv(otmp); return (1); } void ringoff(obj) struct obj *obj; { long mask; mask = obj->owornmask & W_RING; setworn((struct obj *) 0, obj->owornmask); if (!(u.uprops[PROP(obj->otyp)].p_flgs & mask)) impossible("Strange... I didnt know you had that ring."); u.uprops[PROP(obj->otyp)].p_flgs &= ~mask; switch (obj->otyp) { case RIN_FIRE_RESISTANCE: /* Bad luck if the player is in hell... --jgm */ if (!Fire_resistance && dlevel >= 30) { pline("The flames of Hell burn you to a crisp."); killer = "stupidity in hell"; done("burned"); } break; case RIN_LEVITATION: if (!Levitation) { /* no longer floating */ float_down(); } break; case RIN_GAIN_STRENGTH: u.ustr -= obj->spe; u.ustrmax -= obj->spe; if (u.ustr > 118) u.ustr = 118; if (u.ustrmax > 118) u.ustrmax = 118; flags.botl = 1; break; case RIN_INCREASE_DAMAGE: u.udaminc -= obj->spe; break; } } void find_ac() { int uac = 10; if (uarm) uac -= ARM_BONUS(uarm); if (uarm2) uac -= ARM_BONUS(uarm2); if (uarmh) uac -= ARM_BONUS(uarmh); if (uarms) uac -= ARM_BONUS(uarms); if (uarmg) uac -= ARM_BONUS(uarmg); if (uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe; if (uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe; if (uac != u.uac) { u.uac = uac; flags.botl = 1; } } void glibr() { struct obj *otmp; int xfl = 0; if (!uarmg) if (uleft || uright) { /* Note: at present also cursed rings fall off */ pline("Your %s off your fingers.", (uleft && uright) ? "rings slip" : "ring slips"); xfl++; if ((otmp = uleft) != Null(obj)) { ringoff(uleft); dropx(otmp); } if ((otmp = uright) != Null(obj)) { ringoff(uright); dropx(otmp); } } if ((otmp = uwep) != Null(obj)) { /* Note: at present also cursed weapons fall */ setuwep((struct obj *) 0); dropx(otmp); pline("Your weapon %sslips from your hands.", xfl ? "also " : ""); } } struct obj * some_armor() { struct obj *otmph = uarm; if (uarmh && (!otmph || !rn2(4))) otmph = uarmh; if (uarmg && (!otmph || !rn2(4))) otmph = uarmg; if (uarms && (!otmph || !rn2(4))) otmph = uarms; return (otmph); } void corrode_armor() { struct obj *otmph = some_armor(); if (otmph) { if (otmph->rustfree || otmph->otyp == ELVEN_CLOAK || otmph->otyp == LEATHER_ARMOR || otmph->otyp == STUDDED_LEATHER_ARMOR) { pline("Your %s not affected!", aobjnam(otmph, "are")); return; } pline("Your %s!", aobjnam(otmph, "corrode")); otmph->spe--; } } bsd-games-2.17/hack/hack.shknam.c0000664000175000017500000001720207767741711015262 0ustar jsm28jsm28/* $NetBSD: hack.shknam.c,v 1.6 2003/04/02 18:36:40 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.shknam.c,v 1.6 2003/04/02 18:36:40 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" const char *const shkliquors[] = { /* Ukraine */ "Njezjin", "Tsjernigof", "Gomel", "Ossipewsk", "Gorlowka", /* N. Russia */ "Konosja", "Weliki Oestjoeg", "Syktywkar", "Sablja", "Narodnaja", "Kyzyl", /* Silezie */ "Walbrzych", "Swidnica", "Klodzko", "Raciborz", "Gliwice", "Brzeg", "Krnov", "Hradec Kralove", /* Schweiz */ "Leuk", "Brig", "Brienz", "Thun", "Sarnen", "Burglen", "Elm", "Flims", "Vals", "Schuls", "Zum Loch", 0 }; const char *const shkbooks[] = { /* Eire */ "Skibbereen", "Kanturk", "Rath Luirc", "Ennistymon", "Lahinch", "Loughrea", "Croagh", "Maumakeogh", "Ballyjamesduff", "Kinnegad", "Lugnaquillia", "Enniscorthy", "Gweebarra", "Kittamagh", "Nenagh", "Sneem", "Ballingeary", "Kilgarvan", "Cahersiveen", "Glenbeigh", "Kilmihil", "Kiltamagh", "Droichead Atha", "Inniscrone", "Clonegal", "Lisnaskea", "Culdaff", "Dunfanaghy", "Inishbofin", "Kesh", 0 }; const char *const shkarmors[] = { /* Turquie */ "Demirci", "Kalecik", "Boyabai", "Yildizeli", "Gaziantep", "Siirt", "Akhalataki", "Tirebolu", "Aksaray", "Ermenak", "Iskenderun", "Kadirli", "Siverek", "Pervari", "Malasgirt", "Bayburt", "Ayancik", "Zonguldak", "Balya", "Tefenni", "Artvin", "Kars", "Makharadze", "Malazgirt", "Midyat", "Birecik", "Kirikkale", "Alaca", "Polatli", "Nallihan", 0 }; const char *const shkwands[] = { /* Wales */ "Yr Wyddgrug", "Trallwng", "Mallwyd", "Pontarfynach", "Rhaeader", "Llandrindod", "Llanfair-ym-muallt", "Y-Fenni", "Measteg", "Rhydaman", "Beddgelert", "Curig", "Llanrwst", "Llanerchymedd", "Caergybi", /* Scotland */ "Nairn", "Turriff", "Inverurie", "Braemar", "Lochnagar", "Kerloch", "Beinn a Ghlo", "Drumnadrochit", "Morven", "Uist", "Storr", "Sgurr na Ciche", "Cannich", "Gairloch", "Kyleakin", "Dunvegan", 0 }; const char *const shkrings[] = { /* Hollandse familienamen */ "Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken", "Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy", "Olycan", "Sadelin", "Svaving", "Tapper", "Terwen", "Wirix", "Ypey", /* Skandinaviske navne */ "Rastegaisa", "Varjag Njarga", "Kautekeino", "Abisko", "Enontekis", "Rovaniemi", "Avasaksa", "Haparanda", "Lulea", "Gellivare", "Oeloe", "Kajaani", "Fauske", 0 }; const char *const shkfoods[] = { /* Indonesia */ "Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan", "Bandjar", "Parbalingga", "Bojolali", "Sarangan", "Ngebel", "Djombang", "Ardjawinangun", "Berbek", "Papar", "Baliga", "Tjisolok", "Siboga", "Banjoewangi", "Trenggalek", "Karangkobar", "Njalindoeng", "Pasawahan", "Pameunpeuk", "Patjitan", "Kediri", "Pemboeang", "Tringanoe", "Makin", "Tipor", "Semai", "Berhala", "Tegal", "Samoe", 0 }; const char *const shkweapons[] = { /* Perigord */ "Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard", "Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac", "Fleac", "Lonzac", "Vergt", "Queyssac", "Liorac", "Echourgnac", "Cazelon", "Eypau", "Carignan", "Monbazillac", "Jonzac", "Pons", "Jumilhac", "Fenouilledes", "Laguiolet", "Saujon", "Eymoutiers", "Eygurande", "Eauze", "Labouheyre", 0 }; const char *const shkgeneral[] = { /* Suriname */ "Hebiwerie", "Possogroenoe", "Asidonhopo", "Manlobbi", "Adjama", "Pakka Pakka", "Kabalebo", "Wonotobo", "Akalapi", "Sipaliwini", /* Greenland */ "Annootok", "Upernavik", "Angmagssalik", /* N. Canada */ "Aklavik", "Inuvik", "Tuktoyaktuk", "Chicoutimi", "Ouiatchouane", "Chibougamau", "Matagami", "Kipawa", "Kinojevis", "Abitibi", "Maganasipi", /* Iceland */ "Akureyri", "Kopasker", "Budereyri", "Akranes", "Bordeyri", "Holmavik", 0 }; const struct shk_nx { char x; const char *const *xn; } shk_nx[] = { { POTION_SYM, shkliquors }, { SCROLL_SYM, shkbooks }, { ARMOR_SYM, shkarmors }, { WAND_SYM, shkwands }, { RING_SYM, shkrings }, { FOOD_SYM, shkfoods }, { WEAPON_SYM, shkweapons }, { 0, shkgeneral } }; void findname(nampt, let) char *nampt; char let; { const struct shk_nx *p = shk_nx; const char *const *q; int i; while (p->x && p->x != let) p++; q = p->xn; for (i = 0; i < dlevel; i++) if (!q[i]) { /* Not enough names, try general name */ if (let) findname(nampt, 0); else (void) strcpy(nampt, "Dirk"); return; } (void) strncpy(nampt, q[i], PL_NSIZ); nampt[PL_NSIZ - 1] = 0; } bsd-games-2.17/hack/hack.shk.c0000664000175000017500000006667310005547567014576 0ustar jsm28jsm28/* $NetBSD: hack.shk.c,v 1.7 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.shk.c,v 1.7 2004/01/27 20:30:29 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" #ifndef QUEST static void setpaid(void); static void addupbill(void); static void findshk(int); static struct bill_x *onbill(struct obj *); static void pay(long, struct monst *); static int dopayobj(struct bill_x *); static int getprice(struct obj *); static int realhunger(void); #endif #ifdef QUEST int shlevel = 0; struct monst *shopkeeper = 0; struct obj *billobjs = 0; void obfree(obj, merge) struct obj *obj, *merge; { free((char *) obj); } int inshop() { return (0); } void shopdig(n) int n; { } void addtobill(obj) struct obj *obj; { } void subfrombill(obj) struct obj *obj; { } void splitbill(o1, o2) struct obj *o1, *o2; { } int dopay() { return (0); } void paybill() { } int doinvbill(n) int n; { return (0); } void shkdead(m) struct monst *m; { } int shkcatch(obj) struct obj *obj; { return (0); } int shk_move(m) struct monst *m; { return (0); } void replshk(mtmp, mtmp2) struct monst *mtmp, *mtmp2; { } char *shkname(m) struct monst *m; { return (""); } #else /* QUEST */ #include "hack.mfndpos.h" #include "def.mkroom.h" #include "def.eshk.h" #define ESHK(mon) ((struct eshk *)(&(mon->mextra[0]))) #define NOTANGRY(mon) mon->mpeaceful #define ANGRY(mon) !NOTANGRY(mon) /* * Descriptor of current shopkeeper. Note that the bill need not be * per-shopkeeper, since it is valid only when in a shop. */ static struct monst *shopkeeper = 0; static struct bill_x *bill; static int shlevel = 0; /* level of this shopkeeper */ struct obj *billobjs; /* objects on bill with bp->useup */ /* only accessed here and by save & restore */ static long int total; /* filled by addupbill() */ static long int followmsg; /* last time of follow message */ /* invariants: obj->unpaid iff onbill(obj) [unless bp->useup] obj->quan <= bp->bquan */ const char shtypes[] = { /* 8 shoptypes: 7 specialized, 1 mixed */ RING_SYM, WAND_SYM, WEAPON_SYM, FOOD_SYM, SCROLL_SYM, POTION_SYM, ARMOR_SYM, 0 }; static const char *const shopnam[] = { "engagement ring", "walking cane", "antique weapon", "delicatessen", "second hand book", "liquor", "used armor", "assorted antiques" }; char * shkname(mtmp) /* called in do_name.c */ struct monst *mtmp; { return (ESHK(mtmp)->shknam); } void shkdead(mtmp) /* called in mon.c */ struct monst *mtmp; { struct eshk *eshk = ESHK(mtmp); if (eshk->shoplevel == dlevel) rooms[eshk->shoproom].rtype = 0; if (mtmp == shopkeeper) { setpaid(); shopkeeper = 0; bill = (struct bill_x *) - 1000; /* dump core when * referenced */ } } void replshk(mtmp, mtmp2) struct monst *mtmp, *mtmp2; { if (mtmp == shopkeeper) { shopkeeper = mtmp2; bill = &(ESHK(shopkeeper)->bill[0]); } } static void setpaid() { /* caller has checked that shopkeeper exists */ /* either we paid or left the shop or he just died */ struct obj *obj; struct monst *mtmp; for (obj = invent; obj; obj = obj->nobj) obj->unpaid = 0; for (obj = fobj; obj; obj = obj->nobj) obj->unpaid = 0; for (obj = fcobj; obj; obj = obj->nobj) obj->unpaid = 0; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) for (obj = mtmp->minvent; obj; obj = obj->nobj) obj->unpaid = 0; for (mtmp = fallen_down; mtmp; mtmp = mtmp->nmon) for (obj = mtmp->minvent; obj; obj = obj->nobj) obj->unpaid = 0; while ((obj = billobjs) != NULL) { billobjs = obj->nobj; free((char *) obj); } ESHK(shopkeeper)->billct = 0; } static void addupbill() { /* delivers result in total */ /* caller has checked that shopkeeper exists */ int ct = ESHK(shopkeeper)->billct; struct bill_x *bp = bill; total = 0; while (ct--) { total += bp->price * bp->bquan; bp++; } } int inshop() { int roomno = inroom(u.ux, u.uy); /* Did we just leave a shop? */ if (u.uinshop && (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) { if (shopkeeper) { if (ESHK(shopkeeper)->billct) { if (inroom(shopkeeper->mx, shopkeeper->my) == u.uinshop - 1) /* ab@unido */ pline("Somehow you escaped the shop without paying!"); addupbill(); pline("You stole for a total worth of %ld zorkmids.", total); ESHK(shopkeeper)->robbed += total; setpaid(); if ((rooms[ESHK(shopkeeper)->shoproom].rtype == GENERAL) == (rn2(3) == 0)) ESHK(shopkeeper)->following = 1; } shopkeeper = 0; shlevel = 0; } u.uinshop = 0; } /* Did we just enter a zoo of some kind? */ if (roomno >= 0) { int rt = rooms[roomno].rtype; struct monst *mtmp; if (rt == ZOO) { pline("Welcome to David's treasure zoo!"); } else if (rt == SWAMP) { pline("It looks rather muddy down here."); } else if (rt == MORGUE) { if (midnight()) pline("Go away! Go away!"); else pline("You get an uncanny feeling ..."); } else rt = 0; if (rt != 0) { rooms[roomno].rtype = 0; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (rt != ZOO || !rn2(3)) mtmp->msleep = 0; } } /* Did we just enter a shop? */ if (roomno >= 0 && rooms[roomno].rtype >= 8) { if (shlevel != dlevel || !shopkeeper || ESHK(shopkeeper)->shoproom != roomno) findshk(roomno); if (!shopkeeper) { rooms[roomno].rtype = 0; u.uinshop = 0; } else if (!u.uinshop) { if (!ESHK(shopkeeper)->visitct || strncmp(ESHK(shopkeeper)->customer, plname, PL_NSIZ)) { /* He seems to be new here */ ESHK(shopkeeper)->visitct = 0; ESHK(shopkeeper)->following = 0; (void) strncpy(ESHK(shopkeeper)->customer, plname, PL_NSIZ); NOTANGRY(shopkeeper) = 1; } if (!ESHK(shopkeeper)->following) { boolean box, pick; pline("Hello %s! Welcome%s to %s's %s shop!", plname, ESHK(shopkeeper)->visitct++ ? " again" : "", shkname(shopkeeper), shopnam[rooms[ESHK(shopkeeper)->shoproom].rtype - 8]); box = carrying(ICE_BOX); pick = carrying(PICK_AXE); if (box || pick) { if (dochug(shopkeeper)) { u.uinshop = 0; /* he died moving */ return (0); } pline("Will you please leave your %s outside?", (box && pick) ? "box and pick-axe" : box ? "box" : "pick-axe"); } } u.uinshop = roomno + 1; } } return (u.uinshop); } static void findshk(roomno) int roomno; { struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp->isshk && ESHK(mtmp)->shoproom == roomno && ESHK(mtmp)->shoplevel == dlevel) { shopkeeper = mtmp; bill = &(ESHK(shopkeeper)->bill[0]); shlevel = dlevel; if (ANGRY(shopkeeper) && strncmp(ESHK(shopkeeper)->customer, plname, PL_NSIZ)) NOTANGRY(shopkeeper) = 1; /* * billobjs = 0; -- this is wrong if we save in a * shop */ /* * (and it is harmless to have too many things in * billobjs) */ return; } shopkeeper = 0; shlevel = 0; bill = (struct bill_x *) - 1000; /* dump core when referenced */ } static struct bill_x * onbill(obj) struct obj *obj; { struct bill_x *bp; if (!shopkeeper) return (0); for (bp = bill; bp < &bill[ESHK(shopkeeper)->billct]; bp++) if (bp->bo_id == obj->o_id) { if (!obj->unpaid) pline("onbill: paid obj on bill?"); return (bp); } if (obj->unpaid) pline("onbill: unpaid obj not on bill?"); return (0); } /* called with two args on merge */ void obfree(obj, merge) struct obj *obj, *merge; { struct bill_x *bp = onbill(obj); struct bill_x *bpm; if (bp) { if (!merge) { bp->useup = 1; obj->unpaid = 0; /* only for doinvbill */ obj->nobj = billobjs; billobjs = obj; return; } bpm = onbill(merge); if (!bpm) { /* this used to be a rename */ impossible("obfree: not on bill??"); return; } else { /* this was a merger */ bpm->bquan += bp->bquan; ESHK(shopkeeper)->billct--; *bp = bill[ESHK(shopkeeper)->billct]; } } free((char *) obj); } static void pay(tmp, shkp) long tmp; struct monst *shkp; { long robbed = ESHK(shkp)->robbed; u.ugold -= tmp; shkp->mgold += tmp; flags.botl = 1; if (robbed) { robbed -= tmp; if (robbed < 0) robbed = 0; ESHK(shkp)->robbed = robbed; } } int dopay() { long ltmp; struct bill_x *bp; struct monst *shkp; int pass, tmp; multi = 0; (void) inshop(); for (shkp = fmon; shkp; shkp = shkp->nmon) if (shkp->isshk && dist(shkp->mx, shkp->my) < 3) break; if (!shkp && u.uinshop && inroom(shopkeeper->mx, shopkeeper->my) == ESHK(shopkeeper)->shoproom) shkp = shopkeeper; if (!shkp) { pline("There is nobody here to receive your payment."); return (0); } ltmp = ESHK(shkp)->robbed; if (shkp != shopkeeper && NOTANGRY(shkp)) { if (!ltmp) { pline("You do not owe %s anything.", monnam(shkp)); } else if (!u.ugold) { pline("You have no money."); } else { long ugold = u.ugold; if (u.ugold > ltmp) { pline("You give %s the %ld gold pieces he asked for.", monnam(shkp), ltmp); pay(ltmp, shkp); } else { pline("You give %s all your gold.", monnam(shkp)); pay(u.ugold, shkp); } if (ugold < ltmp / 2) { pline("Unfortunately, he doesn't look satisfied."); } else { ESHK(shkp)->robbed = 0; ESHK(shkp)->following = 0; if (ESHK(shkp)->shoplevel != dlevel) { /* * For convenience's sake, let him * disappear */ shkp->minvent = 0; /* %% */ shkp->mgold = 0; mondead(shkp); } } } return (1); } if (!ESHK(shkp)->billct) { pline("You do not owe %s anything.", monnam(shkp)); if (!u.ugold) { pline("Moreover, you have no money."); return (1); } if (ESHK(shkp)->robbed) { #define min(a,b) ((arobbed) ? "partially " : "", monnam(shkp)); pay(min(u.ugold, ESHK(shkp)->robbed), shkp); ESHK(shkp)->robbed = 0; return (1); } if (ANGRY(shkp)) { pline("But in order to appease %s,", amonnam(shkp, "angry")); if (u.ugold >= 1000) { ltmp = 1000; pline(" you give him 1000 gold pieces."); } else { ltmp = u.ugold; pline(" you give him all your money."); } pay(ltmp, shkp); if (strncmp(ESHK(shkp)->customer, plname, PL_NSIZ) || rn2(3)) { pline("%s calms down.", Monnam(shkp)); NOTANGRY(shkp) = 1; } else pline("%s is as angry as ever.", Monnam(shkp)); } return (1); } if (shkp != shopkeeper) { impossible("dopay: not to shopkeeper?"); if (shopkeeper) setpaid(); return (0); } for (pass = 0; pass <= 1; pass++) { tmp = 0; while (tmp < ESHK(shopkeeper)->billct) { bp = &bill[tmp]; if (!pass && !bp->useup) { tmp++; continue; } if (!dopayobj(bp)) return (1); bill[tmp] = bill[--ESHK(shopkeeper)->billct]; } } pline("Thank you for shopping in %s's %s store!", shkname(shopkeeper), shopnam[rooms[ESHK(shopkeeper)->shoproom].rtype - 8]); NOTANGRY(shopkeeper) = 1; return (1); } /* return 1 if paid successfully */ /* 0 if not enough money */ /* -1 if object could not be found (but was paid) */ static int dopayobj(bp) struct bill_x *bp; { struct obj *obj; long ltmp; /* find the object on one of the lists */ obj = bp_to_obj(bp); if (!obj) { impossible("Shopkeeper administration out of order."); setpaid(); /* be nice to the player */ return (0); } if (!obj->unpaid && !bp->useup) { impossible("Paid object on bill??"); return (1); } obj->unpaid = 0; ltmp = bp->price * bp->bquan; if (ANGRY(shopkeeper)) ltmp += ltmp / 3; if (u.ugold < ltmp) { pline("You don't have gold enough to pay %s.", doname(obj)); obj->unpaid = 1; return (0); } pay(ltmp, shopkeeper); pline("You bought %s for %ld gold piece%s.", doname(obj), ltmp, plur(ltmp)); if (bp->useup) { struct obj *otmp = billobjs; if (obj == billobjs) billobjs = obj->nobj; else { while (otmp && otmp->nobj != obj) otmp = otmp->nobj; if (otmp) otmp->nobj = obj->nobj; else pline("Error in shopkeeper administration."); } free((char *) obj); } return (1); } /* routine called after dying (or quitting) with nonempty bill */ void paybill() { if (shlevel == dlevel && shopkeeper && ESHK(shopkeeper)->billct) { addupbill(); if (total > u.ugold) { shopkeeper->mgold += u.ugold; u.ugold = 0; pline("%s comes and takes all your possessions.", Monnam(shopkeeper)); } else { u.ugold -= total; shopkeeper->mgold += total; pline("%s comes and takes the %ld zorkmids you owed him.", Monnam(shopkeeper), total); } setpaid(); /* in case we create bones */ } } /* find obj on one of the lists */ struct obj * bp_to_obj(bp) struct bill_x *bp; { struct obj *obj; struct monst *mtmp; unsigned id = bp->bo_id; if (bp->useup) obj = o_on(id, billobjs); else if (!(obj = o_on(id, invent)) && !(obj = o_on(id, fobj)) && !(obj = o_on(id, fcobj))) { for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if ((obj = o_on(id, mtmp->minvent)) != NULL) break; for (mtmp = fallen_down; mtmp; mtmp = mtmp->nmon) if ((obj = o_on(id, mtmp->minvent)) != NULL) break; } return (obj); } /* called in hack.c when we pickup an object */ void addtobill(obj) struct obj *obj; { struct bill_x *bp; if (!inshop() || (u.ux == ESHK(shopkeeper)->shk.x && u.uy == ESHK(shopkeeper)->shk.y) || (u.ux == ESHK(shopkeeper)->shd.x && u.uy == ESHK(shopkeeper)->shd.y) || onbill(obj) /* perhaps we threw it away earlier */ ) return; if (ESHK(shopkeeper)->billct == BILLSZ) { pline("You got that for free!"); return; } bp = &bill[ESHK(shopkeeper)->billct]; bp->bo_id = obj->o_id; bp->bquan = obj->quan; bp->useup = 0; bp->price = getprice(obj); ESHK(shopkeeper)->billct++; obj->unpaid = 1; } void splitbill(obj, otmp) struct obj *obj, *otmp; { /* otmp has been split off from obj */ struct bill_x *bp; int tmp; bp = onbill(obj); if (!bp) { impossible("splitbill: not on bill?"); return; } if (bp->bquan < otmp->quan) { impossible("Negative quantity on bill??"); } if (bp->bquan == otmp->quan) { impossible("Zero quantity on bill??"); } bp->bquan -= otmp->quan; /* addtobill(otmp); */ if (ESHK(shopkeeper)->billct == BILLSZ) otmp->unpaid = 0; else { tmp = bp->price; bp = &bill[ESHK(shopkeeper)->billct]; bp->bo_id = otmp->o_id; bp->bquan = otmp->quan; bp->useup = 0; bp->price = tmp; ESHK(shopkeeper)->billct++; } } void subfrombill(obj) struct obj *obj; { long ltmp; int tmp; struct obj *otmp; struct bill_x *bp; if (!inshop() || (u.ux == ESHK(shopkeeper)->shk.x && u.uy == ESHK(shopkeeper)->shk.y) || (u.ux == ESHK(shopkeeper)->shd.x && u.uy == ESHK(shopkeeper)->shd.y)) return; if ((bp = onbill(obj)) != 0) { obj->unpaid = 0; if (bp->bquan > obj->quan) { otmp = newobj(0); *otmp = *obj; bp->bo_id = otmp->o_id = flags.ident++; otmp->quan = (bp->bquan -= obj->quan); otmp->owt = 0; /* superfluous */ otmp->onamelth = 0; bp->useup = 1; otmp->nobj = billobjs; billobjs = otmp; return; } ESHK(shopkeeper)->billct--; *bp = bill[ESHK(shopkeeper)->billct]; return; } if (obj->unpaid) { pline("%s didn't notice.", Monnam(shopkeeper)); obj->unpaid = 0; return; /* %% */ } /* he dropped something of his own - probably wants to sell it */ if (shopkeeper->msleep || shopkeeper->mfroz || inroom(shopkeeper->mx, shopkeeper->my) != ESHK(shopkeeper)->shoproom) return; if (ESHK(shopkeeper)->billct == BILLSZ || ((tmp = shtypes[rooms[ESHK(shopkeeper)->shoproom].rtype - 8]) && tmp != obj->olet) || strchr("_0", obj->olet)) { pline("%s seems not interested.", Monnam(shopkeeper)); return; } ltmp = getprice(obj) * obj->quan; if (ANGRY(shopkeeper)) { ltmp /= 3; NOTANGRY(shopkeeper) = 1; } else ltmp /= 2; if (ESHK(shopkeeper)->robbed) { if ((ESHK(shopkeeper)->robbed -= ltmp) < 0) ESHK(shopkeeper)->robbed = 0; pline("Thank you for your contribution to restock this recently plundered shop."); return; } if (ltmp > shopkeeper->mgold) ltmp = shopkeeper->mgold; pay(-ltmp, shopkeeper); if (!ltmp) pline("%s gladly accepts %s but cannot pay you at present.", Monnam(shopkeeper), doname(obj)); else pline("You sold %s and got %ld gold piece%s.", doname(obj), ltmp, plur(ltmp)); } int doinvbill(mode) int mode; /* 0: deliver count 1: paged */ { struct bill_x *bp; struct obj *obj; long totused, thisused; char buf[BUFSZ]; if (mode == 0) { int cnt = 0; if (shopkeeper) for (bp = bill; bp - bill < ESHK(shopkeeper)->billct; bp++) if (bp->useup || ((obj = bp_to_obj(bp)) && obj->quan < bp->bquan)) cnt++; return (cnt); } if (!shopkeeper) { impossible("doinvbill: no shopkeeper?"); return (0); } set_pager(0); if (page_line("Unpaid articles already used up:") || page_line("")) goto quit; totused = 0; for (bp = bill; bp - bill < ESHK(shopkeeper)->billct; bp++) { obj = bp_to_obj(bp); if (!obj) { impossible("Bad shopkeeper administration."); goto quit; } if (bp->useup || bp->bquan > obj->quan) { int cnt, oquan, uquan; oquan = obj->quan; uquan = (bp->useup ? bp->bquan : bp->bquan - oquan); thisused = bp->price * uquan; totused += thisused; obj->quan = uquan; /* cheat doname */ (void) sprintf(buf, "x - %s", doname(obj)); obj->quan = oquan; /* restore value */ for (cnt = 0; buf[cnt]; cnt++); while (cnt < 50) buf[cnt++] = ' '; (void) sprintf(&buf[cnt], " %5ld zorkmids", thisused); if (page_line(buf)) goto quit; } } (void) sprintf(buf, "Total:%50ld zorkmids", totused); if (page_line("") || page_line(buf)) goto quit; set_pager(1); return (0); quit: set_pager(2); return (0); } static int getprice(obj) struct obj *obj; { int tmp, ac; switch (obj->olet) { case AMULET_SYM: tmp = 10 * rnd(500); break; case TOOL_SYM: tmp = 10 * rnd((obj->otyp == EXPENSIVE_CAMERA) ? 150 : 30); break; case RING_SYM: tmp = 10 * rnd(100); break; case WAND_SYM: tmp = 10 * rnd(100); break; case SCROLL_SYM: tmp = 10 * rnd(50); #ifdef MAIL if (obj->otyp == SCR_MAIL) tmp = rnd(5); #endif /* MAIL */ break; case POTION_SYM: tmp = 10 * rnd(50); break; case FOOD_SYM: tmp = 10 * rnd(5 + (2000 / realhunger())); break; case GEM_SYM: tmp = 10 * rnd(20); break; case ARMOR_SYM: ac = ARM_BONUS(obj); if (ac <= -10) /* probably impossible */ ac = -9; tmp = 100 + ac * ac * rnd(10 + ac); break; case WEAPON_SYM: if (obj->otyp < BOOMERANG) tmp = 5 * rnd(10); else if (obj->otyp == LONG_SWORD || obj->otyp == TWO_HANDED_SWORD) tmp = 10 * rnd(150); else tmp = 10 * rnd(75); break; case CHAIN_SYM: pline("Strange ..., carrying a chain?"); case BALL_SYM: tmp = 10; break; default: tmp = 10000; } return (tmp); } static int realhunger() { /* not completely foolproof */ int tmp = u.uhunger; struct obj *otmp = invent; while (otmp) { if (otmp->olet == FOOD_SYM && !otmp->unpaid) tmp += objects[otmp->otyp].nutrition; otmp = otmp->nobj; } return ((tmp <= 0) ? 1 : tmp); } int shkcatch(obj) struct obj *obj; { struct monst *shkp = shopkeeper; if (u.uinshop && shkp && !shkp->mfroz && !shkp->msleep && u.dx && u.dy && inroom(u.ux + u.dx, u.uy + u.dy) + 1 == u.uinshop && shkp->mx == ESHK(shkp)->shk.x && shkp->my == ESHK(shkp)->shk.y && u.ux == ESHK(shkp)->shd.x && u.uy == ESHK(shkp)->shd.y) { pline("%s nimbly catches the %s.", Monnam(shkp), xname(obj)); obj->nobj = shkp->minvent; shkp->minvent = obj; return (1); } return (0); } /* * shk_move: return 1: he moved 0: he didnt -1: let m_move do it */ int shk_move(shkp) struct monst *shkp; { struct monst *mtmp; const struct permonst *mdat = shkp->data; xchar gx, gy, omx, omy, nx, ny, nix, niy; schar appr, i; int udist; int z; schar shkroom, chi, chcnt, cnt; boolean uondoor = 0, satdoor, avoid = 0, badinv; coord poss[9]; int info[9]; struct obj *ib = 0; omx = shkp->mx; omy = shkp->my; if ((udist = dist(omx, omy)) < 3) { if (ANGRY(shkp)) { (void) hitu(shkp, d(mdat->damn, mdat->damd) + 1); return (0); } if (ESHK(shkp)->following) { if (strncmp(ESHK(shkp)->customer, plname, PL_NSIZ)) { pline("Hello %s! I was looking for %s.", plname, ESHK(shkp)->customer); ESHK(shkp)->following = 0; return (0); } if (!ESHK(shkp)->robbed) { /* impossible? */ ESHK(shkp)->following = 0; return (0); } if (moves > followmsg + 4) { pline("Hello %s! Didn't you forget to pay?", plname); followmsg = moves; } if (udist < 2) return (0); } } shkroom = inroom(omx, omy); appr = 1; gx = ESHK(shkp)->shk.x; gy = ESHK(shkp)->shk.y; satdoor = (gx == omx && gy == omy); if (ESHK(shkp)->following || ((z = holetime()) >= 0 && z * z <= udist)) { gx = u.ux; gy = u.uy; if (shkroom < 0 || shkroom != inroom(u.ux, u.uy)) if (udist > 4) return (-1); /* leave it to m_move */ } else if (ANGRY(shkp)) { long saveBlind = Blind; Blind = 0; if (shkp->mcansee && !Invis && cansee(omx, omy)) { gx = u.ux; gy = u.uy; } Blind = saveBlind; avoid = FALSE; } else { #define GDIST(x,y) ((x-gx)*(x-gx)+(y-gy)*(y-gy)) if (Invis) avoid = FALSE; else { uondoor = (u.ux == ESHK(shkp)->shd.x && u.uy == ESHK(shkp)->shd.y); if (uondoor) { if (ESHK(shkp)->billct) pline("Hello %s! Will you please pay before leaving?", plname); badinv = (carrying(PICK_AXE) || carrying(ICE_BOX)); if (satdoor && badinv) return (0); avoid = !badinv; } else { avoid = (u.uinshop && dist(gx, gy) > 8); badinv = FALSE; } if (((!ESHK(shkp)->robbed && !ESHK(shkp)->billct) || avoid) && GDIST(omx, omy) < 3) { if (!badinv && !online(omx, omy)) return (0); if (satdoor) appr = gx = gy = 0; } } } if (omx == gx && omy == gy) return (0); if (shkp->mconf) { avoid = FALSE; appr = 0; } nix = omx; niy = omy; cnt = mfndpos(shkp, poss, info, ALLOW_SSM); if (avoid && uondoor) { /* perhaps we cannot avoid him */ for (i = 0; i < cnt; i++) if (!(info[i] & NOTONL)) goto notonl_ok; avoid = FALSE; notonl_ok: ; } chi = -1; chcnt = 0; for (i = 0; i < cnt; i++) { nx = poss[i].x; ny = poss[i].y; if (levl[nx][ny].typ == ROOM || shkroom != ESHK(shkp)->shoproom || ESHK(shkp)->following) { #ifdef STUPID /* cater for stupid compilers */ int zz; #endif /* STUPID */ if (uondoor && (ib = sobj_at(ICE_BOX, nx, ny))) { nix = nx; niy = ny; chi = i; break; } if (avoid && (info[i] & NOTONL)) continue; if ((!appr && !rn2(++chcnt)) || #ifdef STUPID (appr && (zz = GDIST(nix, niy)) && zz > GDIST(nx, ny)) #else (appr && GDIST(nx, ny) < GDIST(nix, niy)) #endif /* STUPID */ ) { nix = nx; niy = ny; chi = i; } } } if (nix != omx || niy != omy) { if (info[chi] & ALLOW_M) { mtmp = m_at(nix, niy); if (hitmm(shkp, mtmp) == 1 && rn2(3) && hitmm(mtmp, shkp) == 2) return (2); return (0); } else if (info[chi] & ALLOW_U) { (void) hitu(shkp, d(mdat->damn, mdat->damd) + 1); return (0); } shkp->mx = nix; shkp->my = niy; pmon(shkp); if (ib) { freeobj(ib); mpickobj(shkp, ib); } return (1); } return (0); } /* He is digging in the shop. */ void shopdig(fall) int fall; { if (!fall) { if (u.utraptype == TT_PIT) pline("\"Be careful, sir, or you might fall through the floor.\""); else pline("\"Please, do not damage the floor here.\""); } else if (dist(shopkeeper->mx, shopkeeper->my) < 3) { struct obj *obj, *obj2; pline("%s grabs your backpack!", shkname(shopkeeper)); for (obj = invent; obj; obj = obj2) { obj2 = obj->nobj; if (obj->owornmask) continue; freeinv(obj); obj->nobj = shopkeeper->minvent; shopkeeper->minvent = obj; if (obj->unpaid) subfrombill(obj); } } } #endif /* QUEST */ int online(int x, int y) { return (x == u.ux || y == u.uy || (x - u.ux) * (x - u.ux) == (y - u.uy) * (y - u.uy)); } /* Does this monster follow me downstairs? */ int follower(mtmp) struct monst *mtmp; { return (mtmp->mtame || strchr("1TVWZi&, ", mtmp->data->mlet) #ifndef QUEST || (mtmp->isshk && ESHK(mtmp)->following) #endif /* QUEST */ ); } bsd-games-2.17/hack/hack.worn.c0000664000175000017500000001113107767741711014761 0ustar jsm28jsm28/* $NetBSD: hack.worn.c,v 1.5 2003/04/02 18:36:42 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.worn.c,v 1.5 2003/04/02 18:36:42 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" struct worn { long w_mask; struct obj **w_obj; } worn[] = { { W_ARM, &uarm }, { W_ARM2, &uarm2 }, { W_ARMH, &uarmh }, { W_ARMS, &uarms }, { W_ARMG, &uarmg }, { W_RINGL, &uleft }, { W_RINGR, &uright }, { W_WEP, &uwep }, { W_BALL, &uball }, { W_CHAIN, &uchain }, { 0, 0 } }; void setworn(obj, mask) struct obj *obj; long mask; { struct worn *wp; struct obj *oobj; for (wp = worn; wp->w_mask; wp++) if (wp->w_mask & mask) { oobj = *(wp->w_obj); if (oobj && !(oobj->owornmask & wp->w_mask)) impossible("Setworn: mask = %ld.", wp->w_mask); if (oobj) oobj->owornmask &= ~wp->w_mask; if (obj && oobj && wp->w_mask == W_ARM) { if (uarm2) { impossible("Setworn: uarm2 set?"); } else setworn(uarm, W_ARM2); } *(wp->w_obj) = obj; if (obj) obj->owornmask |= wp->w_mask; } if (uarm2 && !uarm) { uarm = uarm2; uarm2 = 0; uarm->owornmask ^= (W_ARM | W_ARM2); } } /* called e.g. when obj is destroyed */ void setnotworn(obj) struct obj *obj; { struct worn *wp; for (wp = worn; wp->w_mask; wp++) if (obj == *(wp->w_obj)) { *(wp->w_obj) = 0; obj->owornmask &= ~wp->w_mask; } if (uarm2 && !uarm) { uarm = uarm2; uarm2 = 0; uarm->owornmask ^= (W_ARM | W_ARM2); } } bsd-games-2.17/hack/pathnames.h.in0000664000175000017500000000342707767741711015472 0ustar jsm28jsm28/* $NetBSD: pathnames.h,v 1.4 2003/08/07 09:37:19 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 5/31/93 */ #define _PATH_MAIL "/usr/bin/mail" #define _PATH_QUEST "/var/games/questdir" #define _PATH_HACK "@hack_dir@" bsd-games-2.17/hack/hack.u_init.c0000664000175000017500000002652110155330535015253 0ustar jsm28jsm28/* $NetBSD: hack.u_init.c,v 1.8 2004/11/05 21:30:32 dsl Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.u_init.c,v 1.8 2004/11/05 21:30:32 dsl Exp $"); #endif /* not lint */ #include #include #include #include "hack.h" #include "extern.h" #define Strcpy (void) strcpy #define Strcat (void) strcat #define UNDEF_TYP 0 #define UNDEF_SPE '\177' struct you zerou; char pl_character[PL_CSIZ]; const char *(roles[]) = { /* must all have distinct first letter */ /* roles[4] may be changed to -woman */ "Tourist", "Speleologist", "Fighter", "Knight", "Cave-man", "Wizard" }; #define NR_OF_ROLES SIZE(roles) char rolesyms[NR_OF_ROLES + 1]; /* filled by u_init() */ struct trobj { uchar trotyp; schar trspe; char trolet; Bitfield(trquan, 6); Bitfield(trknown, 1); }; #ifdef WIZARD struct trobj Extra_objs[] = { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; #endif /* WIZARD */ struct trobj Cave_man[] = { {MACE, 1, WEAPON_SYM, 1, 1}, {BOW, 1, WEAPON_SYM, 1, 1}, {ARROW, 0, WEAPON_SYM, 25, 1}, /* quan is variable */ {LEATHER_ARMOR, 0, ARMOR_SYM, 1, 1}, {0, 0, 0, 0, 0} }; struct trobj Fighter[] = { {TWO_HANDED_SWORD, 0, WEAPON_SYM, 1, 1}, {RING_MAIL, 0, ARMOR_SYM, 1, 1}, {0, 0, 0, 0, 0} }; struct trobj Knight[] = { {LONG_SWORD, 0, WEAPON_SYM, 1, 1}, {SPEAR, 2, WEAPON_SYM, 1, 1}, {RING_MAIL, 1, ARMOR_SYM, 1, 1}, {HELMET, 0, ARMOR_SYM, 1, 1}, {SHIELD, 0, ARMOR_SYM, 1, 1}, {PAIR_OF_GLOVES, 0, ARMOR_SYM, 1, 1}, {0, 0, 0, 0, 0} }; struct trobj Speleologist[] = { {STUDDED_LEATHER_ARMOR, 0, ARMOR_SYM, 1, 1}, {UNDEF_TYP, 0, POTION_SYM, 2, 0}, {FOOD_RATION, 0, FOOD_SYM, 3, 1}, {PICK_AXE, UNDEF_SPE, TOOL_SYM, 1, 0}, {ICE_BOX, 0, TOOL_SYM, 1, 0}, {0, 0, 0, 0, 0} }; struct trobj Tinopener[] = { {CAN_OPENER, 0, TOOL_SYM, 1, 1}, {0, 0, 0, 0, 0} }; struct trobj Tourist[] = { {UNDEF_TYP, 0, FOOD_SYM, 10, 1}, {POT_EXTRA_HEALING, 0, POTION_SYM, 2, 0}, {EXPENSIVE_CAMERA, 0, TOOL_SYM, 1, 1}, {DART, 2, WEAPON_SYM, 25, 1}, /* quan is variable */ {0, 0, 0, 0, 0} }; struct trobj Wizard[] = { {ELVEN_CLOAK, 0, ARMOR_SYM, 1, 1}, {UNDEF_TYP, UNDEF_SPE, WAND_SYM, 2, 0}, {UNDEF_TYP, UNDEF_SPE, RING_SYM, 2, 0}, {UNDEF_TYP, UNDEF_SPE, POTION_SYM, 2, 0}, {UNDEF_TYP, UNDEF_SPE, SCROLL_SYM, 3, 0}, {0, 0, 0, 0, 0} }; void u_init() { int i; char exper = 'y', pc; if (flags.female) /* should have been set in HACKOPTIONS */ roles[4] = "Cave-woman"; for (i = 0; i < NR_OF_ROLES; i++) rolesyms[i] = roles[i][0]; rolesyms[i] = 0; if ((pc = pl_character[0]) != '\0') { if (islower((unsigned char)pc)) pc = toupper((unsigned char)pc); if ((i = role_index(pc)) >= 0) goto got_suffix; /* implies experienced */ printf("\nUnknown role: %c\n", pc); pl_character[0] = pc = 0; } printf("\nAre you an experienced player? [ny] "); while (!strchr("ynYN \n\004", (exper = readchar()))) bell(); if (exper == '\004') /* Give him an opportunity to get out */ end_of_input(); printf("%c\n", exper); /* echo */ if (strchr("Nn \n", exper)) { exper = 0; goto beginner; } printf("\nTell me what kind of character you are:\n"); printf("Are you"); for (i = 0; i < NR_OF_ROLES; i++) { printf(" a %s", roles[i]); if (i == 2) /* %% */ printf(",\n\t"); else if (i < NR_OF_ROLES - 2) printf(","); else if (i == NR_OF_ROLES - 2) printf(" or"); } printf("? [%s] ", rolesyms); while ((pc = readchar()) != '\0') { if (islower((unsigned char)pc)) pc = toupper((unsigned char)pc); if ((i = role_index(pc)) >= 0) { printf("%c\n", pc); /* echo */ (void) fflush(stdout); /* should be seen */ break; } if (pc == '\n') break; if (pc == '\004') /* Give him the opportunity to get * out */ end_of_input(); bell(); } if (pc == '\n') pc = 0; beginner: if (!pc) { printf("\nI'll choose a character for you.\n"); i = rn2(NR_OF_ROLES); pc = rolesyms[i]; printf("This game you will be a%s %s.\n", exper ? "n experienced" : "", roles[i]); getret(); /* give him some feedback in case mklev takes much time */ (void) putchar('\n'); (void) fflush(stdout); } #if 0 /* * Given the above code, I can't see why this would ever change * anything; it does core pretty well, though. - cmh 4/20/93 */ if (exper) { roles[i][0] = pc; } #endif got_suffix: (void) strncpy(pl_character, roles[i], PL_CSIZ - 1); pl_character[PL_CSIZ - 1] = 0; flags.beginner = 1; u = zerou; u.usym = '@'; u.ulevel = 1; init_uhunger(); #ifdef QUEST u.uhorizon = 6; #endif /* QUEST */ uarm = uarm2 = uarmh = uarms = uarmg = uwep = uball = uchain = uleft = uright = 0; switch (pc) { case 'c': case 'C': Cave_man[2].trquan = 12 + rnd(9) * rnd(9); u.uhp = u.uhpmax = 16; u.ustr = u.ustrmax = 18; ini_inv(Cave_man); break; case 't': case 'T': Tourist[3].trquan = 20 + rnd(20); u.ugold = u.ugold0 = rnd(1000); u.uhp = u.uhpmax = 10; u.ustr = u.ustrmax = 8; ini_inv(Tourist); if (!rn2(25)) ini_inv(Tinopener); break; case 'w': case 'W': for (i = 1; i <= 4; i++) if (!rn2(5)) Wizard[i].trquan += rn2(3) - 1; u.uhp = u.uhpmax = 15; u.ustr = u.ustrmax = 16; ini_inv(Wizard); break; case 's': case 'S': Fast = INTRINSIC; Stealth = INTRINSIC; u.uhp = u.uhpmax = 12; u.ustr = u.ustrmax = 10; ini_inv(Speleologist); if (!rn2(10)) ini_inv(Tinopener); break; case 'k': case 'K': u.uhp = u.uhpmax = 12; u.ustr = u.ustrmax = 10; ini_inv(Knight); break; case 'f': case 'F': u.uhp = u.uhpmax = 14; u.ustr = u.ustrmax = 17; ini_inv(Fighter); break; default: /* impossible */ u.uhp = u.uhpmax = 12; u.ustr = u.ustrmax = 16; } find_ac(); if (!rn2(20)) { int d = rn2(7) - 2; /* biased variation */ u.ustr += d; u.ustrmax += d; } #ifdef WIZARD if (wizard) wiz_inv(); #endif /* WIZARD */ /* make sure he can carry all he has - especially for T's */ while (inv_weight() > 0 && u.ustr < 118) u.ustr++, u.ustrmax++; } void ini_inv(trop) struct trobj *trop; { struct obj *obj; while (trop->trolet) { obj = mkobj(trop->trolet); obj->known = trop->trknown; /* not obj->dknown = 1; - let him look at it at least once */ obj->cursed = 0; if (obj->olet == WEAPON_SYM) { obj->quan = trop->trquan; trop->trquan = 1; } if (trop->trspe != UNDEF_SPE) obj->spe = trop->trspe; if (trop->trotyp != UNDEF_TYP) obj->otyp = trop->trotyp; else if (obj->otyp == WAN_WISHING) /* gitpyr!robert */ obj->otyp = WAN_DEATH; obj->owt = weight(obj); /* defined after setting otyp+quan */ obj = addinv(obj); if (obj->olet == ARMOR_SYM) { switch (obj->otyp) { case SHIELD: if (!uarms) setworn(obj, W_ARMS); break; case HELMET: if (!uarmh) setworn(obj, W_ARMH); break; case PAIR_OF_GLOVES: if (!uarmg) setworn(obj, W_ARMG); break; case ELVEN_CLOAK: if (!uarm2) setworn(obj, W_ARM); break; default: if (!uarm) setworn(obj, W_ARM); } } if (obj->olet == WEAPON_SYM) if (!uwep) setuwep(obj); #ifndef PYRAMID_BUG if (--trop->trquan) continue; /* make a similar object */ #else if (trop->trquan) { /* check if zero first */ --trop->trquan; if (trop->trquan) continue; /* make a similar object */ } #endif /* PYRAMID_BUG */ trop++; } } #ifdef WIZARD void wiz_inv() { struct trobj *trop = &Extra_objs[0]; char *ep = getenv("INVENT"); int type; while (ep && *ep) { type = atoi(ep); ep = strchr(ep, ','); if (ep) while (*ep == ',' || *ep == ' ') ep++; if (type <= 0 || type > NROFOBJECTS) continue; trop->trotyp = type; trop->trolet = objects[type].oc_olet; trop->trspe = 4; trop->trknown = 1; trop->trquan = 1; ini_inv(trop); } /* give him a wand of wishing by default */ trop->trotyp = WAN_WISHING; trop->trolet = WAND_SYM; trop->trspe = 20; trop->trknown = 1; trop->trquan = 1; ini_inv(trop); } #endif /* WIZARD */ void plnamesuffix() { char *p; if ((p = strrchr(plname, '-')) != NULL) { *p = 0; pl_character[0] = p[1]; pl_character[1] = 0; if (!plname[0]) { askname(); plnamesuffix(); } } } int role_index(pc) char pc; { /* must be called only from u_init() */ /* so that rolesyms[] is defined */ char *cp; if ((cp = strchr(rolesyms, pc)) != NULL) return (cp - rolesyms); return (-1); } bsd-games-2.17/hack/hack.sh0000664000175000017500000000633307767741711014175 0ustar jsm28jsm28#!/bin/sh # $NetBSD: hack.sh,v 1.3 2003/04/02 18:36:40 jsm Exp $ # # Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, # Amsterdam # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # - Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # - Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # - Neither the name of the Stichting Centrum voor Wiskunde en # Informatica, nor the names of its contributors may be used to endorse or # promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # Copyright (c) 1982 Jay Fenlason # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL # THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # HACKDIR=/usr/games/lib/hackdir HACK=$HACKDIR/hack MAXNROFPLAYERS=4 cd $HACKDIR case $1 in -s*) exec $HACK $@ ;; *) exec $HACK $@ $MAXNROFPLAYERS ;; esac bsd-games-2.17/hack/hack.vault.c0000664000175000017500000002256410005547567015133 0ustar jsm28jsm28/* $NetBSD: hack.vault.c,v 1.7 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.vault.c,v 1.7 2004/01/27 20:30:29 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #ifdef QUEST void setgd( /* mtmp */ ) { /* struct monst *mtmp; */ } int gd_move() { return (2); } void gddead() { } void replgd(mtmp, mtmp2) struct monst *mtmp, *mtmp2; { } void invault() { } #else #include "def.mkroom.h" #define FCSIZ (ROWNO+COLNO) struct fakecorridor { xchar fx, fy, ftyp; }; struct egd { int fcbeg, fcend; /* fcend: first unused pos */ xchar gdx, gdy; /* goal of guard's walk */ unsigned gddone:1; struct fakecorridor fakecorr[FCSIZ]; }; static const struct permonst pm_guard = {"guard", '@', 12, 12, -1, 4, 10, sizeof(struct egd)}; static struct monst *guard; static int gdlevel; #define EGD ((struct egd *)(&(guard->mextra[0]))) static void restfakecorr(void); static int goldincorridor(void); static void restfakecorr() { int fcx, fcy, fcbeg; struct rm *crm; while ((fcbeg = EGD->fcbeg) < EGD->fcend) { fcx = EGD->fakecorr[fcbeg].fx; fcy = EGD->fakecorr[fcbeg].fy; if ((u.ux == fcx && u.uy == fcy) || cansee(fcx, fcy) || m_at(fcx, fcy)) return; crm = &levl[fcx][fcy]; crm->typ = EGD->fakecorr[fcbeg].ftyp; if (!crm->typ) crm->seen = 0; newsym(fcx, fcy); EGD->fcbeg++; } /* it seems he left the corridor - let the guard disappear */ mondead(guard); guard = 0; } static int goldincorridor() { int fci; for (fci = EGD->fcbeg; fci < EGD->fcend; fci++) if (g_at(EGD->fakecorr[fci].fx, EGD->fakecorr[fci].fy)) return (1); return (0); } void setgd() { struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp->isgd) { guard = mtmp; gdlevel = dlevel; return; } guard = 0; } void invault() { int tmp = inroom(u.ux, u.uy); if (tmp < 0 || rooms[tmp].rtype != VAULT) { u.uinvault = 0; return; } if (++u.uinvault % 50 == 0 && (!guard || gdlevel != dlevel)) { char buf[BUFSZ]; int x, y, dd, gx, gy; /* first find the goal for the guard */ for (dd = 1; (dd < ROWNO || dd < COLNO); dd++) { for (y = u.uy - dd; y <= u.uy + dd; y++) { if (y < 0 || y > ROWNO - 1) continue; for (x = u.ux - dd; x <= u.ux + dd; x++) { if (y != u.uy - dd && y != u.uy + dd && x != u.ux - dd) x = u.ux + dd; if (x < 0 || x > COLNO - 1) continue; if (levl[x][y].typ == CORR) goto fnd; } } } impossible("Not a single corridor on this level??"); tele(); return; fnd: gx = x; gy = y; /* next find a good place for a door in the wall */ x = u.ux; y = u.uy; while (levl[x][y].typ == ROOM) { int dx, dy; dx = (gx > x) ? 1 : (gx < x) ? -1 : 0; dy = (gy > y) ? 1 : (gy < y) ? -1 : 0; if (abs(gx - x) >= abs(gy - y)) x += dx; else y += dy; } /* make something interesting happen */ if (!(guard = makemon(&pm_guard, x, y))) return; guard->isgd = guard->mpeaceful = 1; EGD->gddone = 0; gdlevel = dlevel; if (!cansee(guard->mx, guard->my)) { mondead(guard); guard = 0; return; } pline("Suddenly one of the Vault's guards enters!"); pmon(guard); do { pline("\"Hello stranger, who are you?\" - "); getlin(buf); } while (!letter(buf[0])); if (!strcmp(buf, "Croesus") || !strcmp(buf, "Kroisos")) { pline("\"Oh, yes - of course. Sorry to have disturbed you.\""); mondead(guard); guard = 0; return; } clrlin(); pline("\"I don't know you.\""); if (!u.ugold) pline("\"Please follow me.\""); else { pline("\"Most likely all that gold was stolen from this vault.\""); pline("\"Please drop your gold (say d$ ) and follow me.\""); } EGD->gdx = gx; EGD->gdy = gy; EGD->fcbeg = 0; EGD->fakecorr[0].fx = x; EGD->fakecorr[0].fy = y; EGD->fakecorr[0].ftyp = levl[x][y].typ; levl[x][y].typ = DOOR; EGD->fcend = 1; } } int gd_move() { int x, y, dx, dy, gx, gy, nx, ny, typ; struct fakecorridor *fcp; struct rm *crm; if (!guard || gdlevel != dlevel) { impossible("Where is the guard?"); return (2); /* died */ } if (u.ugold || goldincorridor()) return (0); /* didnt move */ if (dist(guard->mx, guard->my) > 1 || EGD->gddone) { restfakecorr(); return (0); /* didnt move */ } x = guard->mx; y = guard->my; /* look around (hor & vert only) for accessible places */ for (nx = x - 1; nx <= x + 1; nx++) for (ny = y - 1; ny <= y + 1; ny++) { if (nx == x || ny == y) if (nx != x || ny != y) if (isok(nx, ny)) if (!IS_WALL(typ = (crm = &levl[nx][ny])->typ) && typ != POOL) { int i; for (i = EGD->fcbeg; i < EGD->fcend; i++) if (EGD->fakecorr[i].fx == nx && EGD->fakecorr[i].fy == ny) goto nextnxy; if ((i = inroom(nx, ny)) >= 0 && rooms[i].rtype == VAULT) goto nextnxy; /* * seems we found a * good place to * leave him alone */ EGD->gddone = 1; if (ACCESSIBLE(typ)) goto newpos; crm->typ = (typ == SCORR) ? CORR : DOOR; goto proceed; } nextnxy: ; } nx = x; ny = y; gx = EGD->gdx; gy = EGD->gdy; dx = (gx > x) ? 1 : (gx < x) ? -1 : 0; dy = (gy > y) ? 1 : (gy < y) ? -1 : 0; if (abs(gx - x) >= abs(gy - y)) nx += dx; else ny += dy; while ((typ = (crm = &levl[nx][ny])->typ) != 0) { /* * in view of the above we must have IS_WALL(typ) or typ == * POOL */ /* must be a wall here */ if (isok(nx + nx - x, ny + ny - y) && typ != POOL && ZAP_POS(levl[nx + nx - x][ny + ny - y].typ)) { crm->typ = DOOR; goto proceed; } if (dy && nx != x) { nx = x; ny = y + dy; continue; } if (dx && ny != y) { ny = y; nx = x + dx; dy = 0; continue; } /* I don't like this, but ... */ crm->typ = DOOR; goto proceed; } crm->typ = CORR; proceed: if (cansee(nx, ny)) { mnewsym(nx, ny); prl(nx, ny); } fcp = &(EGD->fakecorr[EGD->fcend]); if (EGD->fcend++ == FCSIZ) panic("fakecorr overflow"); fcp->fx = nx; fcp->fy = ny; fcp->ftyp = typ; newpos: if (EGD->gddone) nx = ny = 0; guard->mx = nx; guard->my = ny; pmon(guard); restfakecorr(); return (1); } void gddead() { guard = 0; } void replgd(mtmp, mtmp2) struct monst *mtmp, *mtmp2; { if (mtmp == guard) guard = mtmp2; } #endif /* QUEST */ bsd-games-2.17/hack/hack.mkshop.c0000664000175000017500000002362307767741711015306 0ustar jsm28jsm28/* $NetBSD: hack.mkshop.c,v 1.8 2003/04/02 18:36:38 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.mkshop.c,v 1.8 2003/04/02 18:36:38 jsm Exp $"); #endif /* not lint */ #include #ifndef QUEST #include "hack.h" #include "extern.h" #include "def.mkroom.h" #include "def.eshk.h" #define ESHK ((struct eshk *)(&(shk->mextra[0]))) const schar shprobs[] = {3, 3, 5, 5, 10, 10, 14, 50}; /* their probabilities */ void mkshop() { struct mkroom *sroom; int sh, sx, sy, i = -1; char let; int roomno; struct monst *shk; #ifdef WIZARD /* first determine shoptype */ if (wizard) { char *ep = getenv("SHOPTYPE"); if (ep) { if (*ep == 'z' || *ep == 'Z') { mkzoo(ZOO); return; } if (*ep == 'm' || *ep == 'M') { mkzoo(MORGUE); return; } if (*ep == 'b' || *ep == 'B') { mkzoo(BEEHIVE); return; } if (*ep == 's' || *ep == 'S') { mkswamp(); return; } for (i = 0; shtypes[i]; i++) if (*ep == shtypes[i]) break; goto gottype; } } gottype: #endif /* WIZARD */ for (sroom = &rooms[0], roomno = 0;; sroom++, roomno++) { if (sroom->hx < 0) return; if (sroom - rooms >= nroom) { pline("rooms not closed by -1?"); return; } if (sroom->rtype) continue; if (!sroom->rlit || has_dnstairs(sroom) || has_upstairs(sroom)) continue; if ( #ifdef WIZARD (wizard && getenv("SHOPTYPE") && sroom->doorct != 0) || #endif /* WIZARD */ sroom->doorct == 1) break; } if (i < 0) { /* shoptype not yet determined */ int j; for (j = rn2(100), i = 0; (j -= shprobs[i]) >= 0; i++) if (!shtypes[i]) break; /* superfluous */ if (isbig(sroom) && i + SHOPBASE == WANDSHOP) i = GENERAL - SHOPBASE; } sroom->rtype = i + SHOPBASE; let = shtypes[i]; sh = sroom->fdoor; sx = doors[sh].x; sy = doors[sh].y; if (sx == sroom->lx - 1) sx++; else if (sx == sroom->hx + 1) sx--; else if (sy == sroom->ly - 1) sy++; else if (sy == sroom->hy + 1) sy--; else { #ifdef WIZARD /* This is said to happen sometimes, but I've never seen it. */ if (wizard) { int j = sroom->doorct; pline("Where is shopdoor?"); pline("Room at (%d,%d),(%d,%d).", sroom->lx, sroom->ly, sroom->hx, sroom->hy); pline("doormax=%d doorct=%d fdoor=%d", doorindex, sroom->doorct, sh); while (j--) { pline("door [%d,%d]", doors[sh].x, doors[sh].y); sh++; } more(); } #endif /* WIZARD */ return; } if (!(shk = makemon(PM_SHK, sx, sy))) return; shk->isshk = shk->mpeaceful = 1; shk->msleep = 0; shk->mtrapseen = ~0; /* we know all the traps already */ ESHK->shoproom = roomno; ESHK->shoplevel = dlevel; ESHK->shd = doors[sh]; ESHK->shk.x = sx; ESHK->shk.y = sy; ESHK->robbed = 0; ESHK->visitct = 0; ESHK->following = 0; shk->mgold = 1000 + 30 * rnd(100); /* initial capital */ ESHK->billct = 0; findname(ESHK->shknam, let); for (sx = sroom->lx; sx <= sroom->hx; sx++) for (sy = sroom->ly; sy <= sroom->hy; sy++) { struct monst *mtmp; if ((sx == sroom->lx && doors[sh].x == sx - 1) || (sx == sroom->hx && doors[sh].x == sx + 1) || (sy == sroom->ly && doors[sh].y == sy - 1) || (sy == sroom->hy && doors[sh].y == sy + 1)) continue; if (rn2(100) < dlevel && !m_at(sx, sy) && (mtmp = makemon(PM_MIMIC, sx, sy))) { mtmp->mimic = 1; mtmp->mappearance = (let && rn2(10) < dlevel) ? let : ']'; continue; } (void) mkobj_at(let, sx, sy); } } void mkzoo(type) int type; { struct mkroom *sroom; struct monst *mon; int sh, sx, sy, i; int goldlim = 500 * dlevel; int moct = 0; i = nroom; for (sroom = &rooms[rn2(nroom)];; sroom++) { if (sroom == &rooms[nroom]) sroom = &rooms[0]; if (!i-- || sroom->hx < 0) return; if (sroom->rtype) continue; if (type == MORGUE && sroom->rlit) continue; if (has_upstairs(sroom) || (has_dnstairs(sroom) && rn2(3))) continue; if (sroom->doorct == 1 || !rn2(5)) break; } sroom->rtype = type; sh = sroom->fdoor; for (sx = sroom->lx; sx <= sroom->hx; sx++) for (sy = sroom->ly; sy <= sroom->hy; sy++) { if ((sx == sroom->lx && doors[sh].x == sx - 1) || (sx == sroom->hx && doors[sh].x == sx + 1) || (sy == sroom->ly && doors[sh].y == sy - 1) || (sy == sroom->hy && doors[sh].y == sy + 1)) continue; mon = makemon( (type == MORGUE) ? morguemon() : (type == BEEHIVE) ? PM_KILLER_BEE : (struct permonst *) 0, sx, sy); if (mon) mon->msleep = 1; switch (type) { case ZOO: i = sq(dist2(sx, sy, doors[sh].x, doors[sh].y)); if (i >= goldlim) i = 5 * dlevel; goldlim -= i; mkgold((long) (10 + rn2(i)), sx, sy); break; case MORGUE: /* * Usually there is one dead body in the * morgue */ if (!moct && rn2(3)) { mksobj_at(CORPSE, sx, sy); moct++; } break; case BEEHIVE: if (!rn2(3)) mksobj_at(LUMP_OF_ROYAL_JELLY, sx, sy); break; } } } const struct permonst * morguemon() { int i = rn2(100), hd = rn2(dlevel); if (hd > 10 && i < 10) return (PM_DEMON); if (hd > 8 && i > 85) return (PM_VAMPIRE); return ((i < 40) ? PM_GHOST : (i < 60) ? PM_WRAITH : PM_ZOMBIE); } void mkswamp() { /* Michiel Huisjes & Fred de Wilde */ struct mkroom *sroom; int sx, sy, i, eelct = 0; for (i = 0; i < 5; i++) { /* 5 tries */ sroom = &rooms[rn2(nroom)]; if (sroom->hx < 0 || sroom->rtype || has_upstairs(sroom) || has_dnstairs(sroom)) continue; /* satisfied; make a swamp */ sroom->rtype = SWAMP; for (sx = sroom->lx; sx <= sroom->hx; sx++) for (sy = sroom->ly; sy <= sroom->hy; sy++) if ((sx + sy) % 2 && !o_at(sx, sy) && !t_at(sx, sy) && !m_at(sx, sy) && !nexttodoor(sx, sy)) { levl[sx][sy].typ = POOL; levl[sx][sy].scrsym = POOL_SYM; if (!eelct || !rn2(4)) { (void) makemon(PM_EEL, sx, sy); eelct++; } } } } int nexttodoor(sx, sy) int sx, sy; { int dx, dy; struct rm *lev; for (dx = -1; dx <= 1; dx++) for (dy = -1; dy <= 1; dy++) if ((lev = &levl[sx + dx][sy + dy])->typ == DOOR || lev->typ == SDOOR || lev->typ == LDOOR) return (1); return (0); } int has_dnstairs(sroom) struct mkroom *sroom; { return (sroom->lx <= xdnstair && xdnstair <= sroom->hx && sroom->ly <= ydnstair && ydnstair <= sroom->hy); } int has_upstairs(sroom) struct mkroom *sroom; { return (sroom->lx <= xupstair && xupstair <= sroom->hx && sroom->ly <= yupstair && yupstair <= sroom->hy); } int isbig(sroom) struct mkroom *sroom; { int area = (sroom->hx - sroom->lx) * (sroom->hy - sroom->ly); return (area > 20); } int dist2(x0, y0, x1, y1) int x0, y0, x1, y1; { return ((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)); } int sq(a) int a; { return (a * a); } #endif /* QUEST */ bsd-games-2.17/hack/hack.c0000664000175000017500000005371107767741711014007 0ustar jsm28jsm28/* $NetBSD: hack.c,v 1.6 2003/04/02 18:36:35 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.c,v 1.6 2003/04/02 18:36:35 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" /* * called on movement: 1. when throwing ball+chain far away 2. when * teleporting 3. when walking out of a lit room */ void unsee() { int x, y; struct rm *lev; /* if(u.udispl){ u.udispl = 0; newsym(u.udisx, u.udisy); } */ #ifndef QUEST if (seehx) { seehx = 0; } else #endif /* QUEST */ for (x = u.ux - 1; x < u.ux + 2; x++) for (y = u.uy - 1; y < u.uy + 2; y++) { if (!isok(x, y)) continue; lev = &levl[x][y]; if (!lev->lit && lev->scrsym == '.') { lev->scrsym = ' '; lev->new = 1; on_scr(x, y); } } } /* * called: in hack.eat.c: seeoff(0) - blind after eating rotten food in * hack.mon.c: seeoff(0) - blinded by a yellow light in hack.mon.c: seeoff(1) * - swallowed in hack.do.c: seeoff(0) - blind after drinking potion in * hack.do.c: seeoff(1) - go up or down the stairs in hack.trap.c:seeoff(1) * - fall through trapdoor */ void seeoff(mode) int mode; /* 1 to redo @, 0 to leave them *//* 1 means * misc movement, 0 means blindness */ { int x, y; struct rm *lev; if (u.udispl && mode) { u.udispl = 0; levl[u.udisx][u.udisy].scrsym = news0(u.udisx, u.udisy); } #ifndef QUEST if (seehx) { seehx = 0; } else #endif /* QUEST */ if (!mode) { for (x = u.ux - 1; x < u.ux + 2; x++) for (y = u.uy - 1; y < u.uy + 2; y++) { if (!isok(x, y)) continue; lev = &levl[x][y]; if (!lev->lit && lev->scrsym == '.') lev->seen = 0; } } } void domove() { xchar oldx, oldy; struct monst *mtmp = NULL; struct rm *tmpr, *ust; struct trap *trap = NULL; struct obj *otmp = NULL; u_wipe_engr(rnd(5)); if (inv_weight() > 0) { pline("You collapse under your load."); nomul(0); return; } if (u.uswallow) { u.dx = u.dy = 0; u.ux = u.ustuck->mx; u.uy = u.ustuck->my; } else { if (Confusion) { do { confdir(); } while (!isok(u.ux + u.dx, u.uy + u.dy) || IS_ROCK(levl[u.ux + u.dx][u.uy + u.dy].typ)); } if (!isok(u.ux + u.dx, u.uy + u.dy)) { nomul(0); return; } } ust = &levl[u.ux][u.uy]; oldx = u.ux; oldy = u.uy; if (!u.uswallow && (trap = t_at(u.ux + u.dx, u.uy + u.dy)) && trap->tseen) nomul(0); if (u.ustuck && !u.uswallow && (u.ux + u.dx != u.ustuck->mx || u.uy + u.dy != u.ustuck->my)) { if (dist(u.ustuck->mx, u.ustuck->my) > 2) { /* perhaps it fled (or was teleported or ... ) */ u.ustuck = 0; } else { if (Blind) pline("You cannot escape from it!"); else pline("You cannot escape from %s!", monnam(u.ustuck)); nomul(0); return; } } if (u.uswallow || (mtmp = m_at(u.ux + u.dx, u.uy + u.dy))) { /* attack monster */ nomul(0); gethungry(); if (multi < 0) return; /* we just fainted */ /* try to attack; note that it might evade */ if (attack(u.uswallow ? u.ustuck : mtmp)) return; } /* not attacking an animal, so we try to move */ if (u.utrap) { if (u.utraptype == TT_PIT) { pline("You are still in a pit."); u.utrap--; } else { pline("You are caught in a beartrap."); if ((u.dx && u.dy) || !rn2(5)) u.utrap--; } return; } tmpr = &levl[u.ux + u.dx][u.uy + u.dy]; if (IS_ROCK(tmpr->typ) || (u.dx && u.dy && (tmpr->typ == DOOR || ust->typ == DOOR))) { flags.move = 0; nomul(0); return; } while ((otmp = sobj_at(ENORMOUS_ROCK, u.ux + u.dx, u.uy + u.dy)) != NULL){ xchar rx = u.ux + 2 * u.dx, ry = u.uy + 2 * u.dy; struct trap *ttmp; nomul(0); if (isok(rx, ry) && !IS_ROCK(levl[rx][ry].typ) && (levl[rx][ry].typ != DOOR || !(u.dx && u.dy)) && !sobj_at(ENORMOUS_ROCK, rx, ry)) { if (m_at(rx, ry)) { pline("You hear a monster behind the rock."); pline("Perhaps that's why you cannot move it."); goto cannot_push; } if ((ttmp = t_at(rx, ry)) != NULL) switch (ttmp->ttyp) { case PIT: pline("You push the rock into a pit!"); deltrap(ttmp); delobj(otmp); pline("It completely fills the pit!"); continue; case TELEP_TRAP: pline("You push the rock and suddenly it disappears!"); delobj(otmp); continue; } if (levl[rx][ry].typ == POOL) { levl[rx][ry].typ = ROOM; mnewsym(rx, ry); prl(rx, ry); pline("You push the rock into the water."); pline("Now you can cross the water!"); delobj(otmp); continue; } otmp->ox = rx; otmp->oy = ry; /* pobj(otmp); */ if (cansee(rx, ry)) atl(rx, ry, otmp->olet); if (Invisible) newsym(u.ux + u.dx, u.uy + u.dy); { static long lastmovetime; /* * note: this var contains garbage initially * and after a restore */ if (moves > lastmovetime + 2 || moves < lastmovetime) pline("With great effort you move the enormous rock."); lastmovetime = moves; } } else { pline("You try to move the enormous rock, but in vain."); cannot_push: if ((!invent || inv_weight() + 90 <= 0) && (!u.dx || !u.dy || (IS_ROCK(levl[u.ux][u.uy + u.dy].typ) && IS_ROCK(levl[u.ux + u.dx][u.uy].typ)))) { pline("However, you can squeeze yourself into a small opening."); break; } else return; } } if (u.dx && u.dy && IS_ROCK(levl[u.ux][u.uy + u.dy].typ) && IS_ROCK(levl[u.ux + u.dx][u.uy].typ) && invent && inv_weight() + 40 > 0) { pline("You are carrying too much to get through."); nomul(0); return; } if (Punished && DIST(u.ux + u.dx, u.uy + u.dy, uchain->ox, uchain->oy) > 2) { if (carried(uball)) { movobj(uchain, u.ux, u.uy); goto nodrag; } if (DIST(u.ux + u.dx, u.uy + u.dy, uball->ox, uball->oy) < 3) { /* leave ball, move chain under/over ball */ movobj(uchain, uball->ox, uball->oy); goto nodrag; } if (inv_weight() + (int) uball->owt / 2 > 0) { pline("You cannot %sdrag the heavy iron ball.", invent ? "carry all that and also " : ""); nomul(0); return; } movobj(uball, uchain->ox, uchain->oy); unpobj(uball); /* BAH %% */ uchain->ox = u.ux; uchain->oy = u.uy; nomul(-2); nomovemsg = ""; nodrag: ; } u.ux += u.dx; u.uy += u.dy; if (flags.run) { if (tmpr->typ == DOOR || (xupstair == u.ux && yupstair == u.uy) || (xdnstair == u.ux && ydnstair == u.uy)) nomul(0); } if (tmpr->typ == POOL && !Levitation) drown(); /* not necessarily fatal */ /* if(u.udispl) { u.udispl = 0; newsym(oldx,oldy); } */ if (!Blind) { #ifdef QUEST setsee(); #else if (ust->lit) { if (tmpr->lit) { if (tmpr->typ == DOOR) prl1(u.ux + u.dx, u.uy + u.dy); else if (ust->typ == DOOR) nose1(oldx - u.dx, oldy - u.dy); } else { unsee(); prl1(u.ux + u.dx, u.uy + u.dy); } } else { if (tmpr->lit) setsee(); else { prl1(u.ux + u.dx, u.uy + u.dy); if (tmpr->typ == DOOR) { if (u.dy) { prl(u.ux - 1, u.uy); prl(u.ux + 1, u.uy); } else { prl(u.ux, u.uy - 1); prl(u.ux, u.uy + 1); } } } nose1(oldx - u.dx, oldy - u.dy); } #endif /* QUEST */ } else { pru(); } if (!flags.nopick) pickup(1); if (trap) dotrap(trap); /* fall into pit, arrow trap, etc. */ (void) inshop(); if (!Blind) read_engr_at(u.ux, u.uy); } void movobj(obj, ox, oy) struct obj *obj; int ox, oy; { /* Some dirty programming to get display right */ freeobj(obj); unpobj(obj); obj->nobj = fobj; fobj = obj; obj->ox = ox; obj->oy = oy; } int dopickup() { if (!g_at(u.ux, u.uy) && !o_at(u.ux, u.uy)) { pline("There is nothing here to pick up."); return (0); } if (Levitation) { pline("You cannot reach the floor."); return (1); } pickup(0); return (1); } void pickup(int all) { struct gold *gold; struct obj *obj, *obj2; int wt; if (Levitation) return; while ((gold = g_at(u.ux, u.uy)) != NULL) { pline("%ld gold piece%s.", gold->amount, plur(gold->amount)); u.ugold += gold->amount; flags.botl = 1; freegold(gold); if (flags.run) nomul(0); if (Invisible) newsym(u.ux, u.uy); } /* check for more than one object */ if (!all) { int ct = 0; for (obj = fobj; obj; obj = obj->nobj) if (obj->ox == u.ux && obj->oy == u.uy) if (!Punished || obj != uchain) ct++; if (ct < 2) all++; else pline("There are several objects here."); } for (obj = fobj; obj; obj = obj2) { obj2 = obj->nobj; /* perhaps obj will be picked up */ if (obj->ox == u.ux && obj->oy == u.uy) { if (flags.run) nomul(0); /* do not pick up uchain */ if (Punished && obj == uchain) continue; if (!all) { char c; pline("Pick up %s ? [ynaq]", doname(obj)); while (!strchr("ynaq ", (c = readchar()))) bell(); if (c == 'q') return; if (c == 'n') continue; if (c == 'a') all = 1; } if (obj->otyp == DEAD_COCKATRICE && !uarmg) { pline("Touching the dead cockatrice is a fatal mistake."); pline("You turn to stone."); killer = "cockatrice cadaver"; done("died"); } if (obj->otyp == SCR_SCARE_MONSTER) { if (!obj->spe) obj->spe = 1; else { /* * Note: perhaps the 1st pickup * failed: you cannot carry anymore, * and so we never dropped it - let's * assume that treading on it twice * also destroys the scroll */ pline("The scroll turns to dust as you pick it up."); delobj(obj); continue; } } wt = inv_weight() + obj->owt; if (wt > 0) { if (obj->quan > 1) { /* see how many we can lift */ int savequan = obj->quan; int iw = inv_weight(); int qq; for (qq = 1; qq < savequan; qq++) { obj->quan = qq; if (iw + weight(obj) > 0) break; } obj->quan = savequan; qq--; /* we can carry qq of them */ if (!qq) goto too_heavy; pline("You can only carry %s of the %s lying here.", (qq == 1) ? "one" : "some", doname(obj)); (void) splitobj(obj, qq); /* * note: obj2 is set already, so * we'll never encounter the other * half; if it should be otherwise * then write obj2 = * splitobj(obj,qq); */ goto lift_some; } too_heavy: pline("There %s %s here, but %s.", (obj->quan == 1) ? "is" : "are", doname(obj), !invent ? "it is too heavy for you to lift" : "you cannot carry anymore"); break; } lift_some: if (inv_cnt() >= 52) { pline("Your knapsack cannot accomodate anymore items."); break; } if (wt > -5) pline("You have a little trouble lifting"); freeobj(obj); if (Invisible) newsym(u.ux, u.uy); addtobill(obj); /* sets obj->unpaid if necessary */ { int pickquan = obj->quan; int mergquan; if (!Blind) obj->dknown = 1; /* this is done by * prinv(), but addinv() * needs it already for * merging */ obj = addinv(obj); /* might merge it with * other objects */ mergquan = obj->quan; obj->quan = pickquan; /* to fool prinv() */ prinv(obj); obj->quan = mergquan; } } } } /* stop running if we see something interesting */ /* turn around a corner if that is the only way we can proceed */ /* do not turn left or right twice */ void lookaround() { int x, y, i, x0 = 0, y0 = 0, m0 = 0, i0 = 9; int corrct = 0, noturn = 0; struct monst *mtmp; if (Blind || flags.run == 0) return; if (flags.run == 1 && levl[u.ux][u.uy].typ == ROOM) return; #ifdef QUEST if (u.ux0 == u.ux + u.dx && u.uy0 == u.uy + u.dy) goto stop; #endif /* QUEST */ for (x = u.ux - 1; x <= u.ux + 1; x++) for (y = u.uy - 1; y <= u.uy + 1; y++) { if (x == u.ux && y == u.uy) continue; if (!levl[x][y].typ) continue; if ((mtmp = m_at(x, y)) && !mtmp->mimic && (!mtmp->minvis || See_invisible)) { if (!mtmp->mtame || (x == u.ux + u.dx && y == u.uy + u.dy)) goto stop; } else mtmp = 0; /* invisible M cannot * influence us */ if (x == u.ux - u.dx && y == u.uy - u.dy) continue; switch (levl[x][y].scrsym) { case '|': case '-': case '.': case ' ': break; case '+': if (x != u.ux && y != u.uy) break; if (flags.run != 1) goto stop; /* fall into next case */ case CORR_SYM: corr: if (flags.run == 1 || flags.run == 3) { i = DIST(x, y, u.ux + u.dx, u.uy + u.dy); if (i > 2) break; if (corrct == 1 && DIST(x, y, x0, y0) != 1) noturn = 1; if (i < i0) { i0 = i; x0 = x; y0 = y; m0 = mtmp ? 1 : 0; } } corrct++; break; case '^': if (flags.run == 1) goto corr; /* if you must */ if (x == u.ux + u.dx && y == u.uy + u.dy) goto stop; break; default: /* e.g. objects or trap or stairs */ if (flags.run == 1) goto corr; if (mtmp) break; /* d */ stop: nomul(0); return; } } #ifdef QUEST if (corrct > 0 && (flags.run == 4 || flags.run == 5)) goto stop; #endif /* QUEST */ if (corrct > 1 && flags.run == 2) goto stop; if ((flags.run == 1 || flags.run == 3) && !noturn && !m0 && i0 && (corrct == 1 || (corrct == 2 && i0 == 1))) { /* make sure that we do not turn too far */ if (i0 == 2) { if (u.dx == y0 - u.uy && u.dy == u.ux - x0) i = 2; /* straight turn right */ else i = -2; /* straight turn left */ } else if (u.dx && u.dy) { if ((u.dx == u.dy && y0 == u.uy) || (u.dx != u.dy && y0 != u.uy)) i = -1; /* half turn left */ else i = 1; /* half turn right */ } else { if ((x0 - u.ux == y0 - u.uy && !u.dy) || (x0 - u.ux != y0 - u.uy && u.dy)) i = 1; /* half turn right */ else i = -1; /* half turn left */ } i += u.last_str_turn; if (i <= 2 && i >= -2) { u.last_str_turn = i; u.dx = x0 - u.ux, u.dy = y0 - u.uy; } } } /* something like lookaround, but we are not running */ /* react only to monsters that might hit us */ int monster_nearby() { int x, y; struct monst *mtmp; if (!Blind) for (x = u.ux - 1; x <= u.ux + 1; x++) for (y = u.uy - 1; y <= u.uy + 1; y++) { if (x == u.ux && y == u.uy) continue; if ((mtmp = m_at(x, y)) && !mtmp->mimic && !mtmp->mtame && !mtmp->mpeaceful && !strchr("Ea", mtmp->data->mlet) && !mtmp->mfroz && !mtmp->msleep && /* aplvax!jcn */ (!mtmp->minvis || See_invisible)) return (1); } return (0); } #ifdef QUEST int cansee(x, y) xchar x, y; { int dx, dy, adx, ady, sdx, sdy, dmax, d; if (Blind) return (0); if (!isok(x, y)) return (0); d = dist(x, y); if (d < 3) return (1); if (d > u.uhorizon * u.uhorizon) return (0); if (!levl[x][y].lit) return (0); dx = x - u.ux; adx = abs(dx); sdx = sgn(dx); dy = y - u.uy; ady = abs(dy); sdy = sgn(dy); if (dx == 0 || dy == 0 || adx == ady) { dmax = (dx == 0) ? ady : adx; for (d = 1; d <= dmax; d++) if (!rroom(sdx * d, sdy * d)) return (0); return (1); } else if (ady > adx) { for (d = 1; d <= ady; d++) { if (!rroom(sdx * ((d * adx) / ady), sdy * d) || !rroom(sdx * ((d * adx - 1) / ady + 1), sdy * d)) return (0); } return (1); } else { for (d = 1; d <= adx; d++) { if (!rroom(sdx * d, sdy * ((d * ady) / adx)) || !rroom(sdx * d, sdy * ((d * ady - 1) / adx + 1))) return (0); } return (1); } } int rroom(x, y) int x, y; { return (IS_ROOM(levl[u.ux + x][u.uy + y].typ)); } #else int cansee(x, y) xchar x, y; { if (Blind || u.uswallow) return (0); if (dist(x, y) < 3) return (1); if (levl[x][y].lit && seelx <= x && x <= seehx && seely <= y && y <= seehy) return (1); return (0); } #endif /* QUEST */ int sgn(a) int a; { return ((a > 0) ? 1 : (a == 0) ? 0 : -1); } #ifdef QUEST void setsee() { int x, y; if (Blind) { pru(); return; } for (y = u.uy - u.uhorizon; y <= u.uy + u.uhorizon; y++) for (x = u.ux - u.uhorizon; x <= u.ux + u.uhorizon; x++) { if (cansee(x, y)) prl(x, y); } } #else void setsee() { int x, y; if (Blind) { pru(); return; } if (!levl[u.ux][u.uy].lit) { seelx = u.ux - 1; seehx = u.ux + 1; seely = u.uy - 1; seehy = u.uy + 1; } else { for (seelx = u.ux; levl[seelx - 1][u.uy].lit; seelx--); for (seehx = u.ux; levl[seehx + 1][u.uy].lit; seehx++); for (seely = u.uy; levl[u.ux][seely - 1].lit; seely--); for (seehy = u.uy; levl[u.ux][seehy + 1].lit; seehy++); } for (y = seely; y <= seehy; y++) for (x = seelx; x <= seehx; x++) { prl(x, y); } if (!levl[u.ux][u.uy].lit) seehx = 0; /* seems necessary elsewhere */ else { if (seely == u.uy) for (x = u.ux - 1; x <= u.ux + 1; x++) prl(x, seely - 1); if (seehy == u.uy) for (x = u.ux - 1; x <= u.ux + 1; x++) prl(x, seehy + 1); if (seelx == u.ux) for (y = u.uy - 1; y <= u.uy + 1; y++) prl(seelx - 1, y); if (seehx == u.ux) for (y = u.uy - 1; y <= u.uy + 1; y++) prl(seehx + 1, y); } } #endif /* QUEST */ void nomul(nval) int nval; { if (multi < 0) return; multi = nval; flags.mv = flags.run = 0; } int abon() { if (u.ustr == 3) return (-3); else if (u.ustr < 6) return (-2); else if (u.ustr < 8) return (-1); else if (u.ustr < 17) return (0); else if (u.ustr < 69) return (1); /* up to 18/50 */ else if (u.ustr < 118) return (2); else return (3); } int dbon() { if (u.ustr < 6) return (-1); else if (u.ustr < 16) return (0); else if (u.ustr < 18) return (1); else if (u.ustr == 18) return (2); /* up to 18 */ else if (u.ustr < 94) return (3); /* up to 18/75 */ else if (u.ustr < 109) return (4); /* up to 18/90 */ else if (u.ustr < 118) return (5); /* up to 18/99 */ else return (6); } void losestr(num) /* may kill you; cause may be poison or */ int num; /* monster like 'A' */ { u.ustr -= num; while (u.ustr < 3) { u.ustr++; u.uhp -= 6; u.uhpmax -= 6; } flags.botl = 1; } void losehp(n, knam) int n; const char *knam; { u.uhp -= n; if (u.uhp > u.uhpmax) u.uhpmax = u.uhp; /* perhaps n was negative */ flags.botl = 1; if (u.uhp < 1) { killer = knam; /* the thing that killed you */ done("died"); } } void losehp_m(n, mtmp) int n; struct monst *mtmp; { u.uhp -= n; flags.botl = 1; if (u.uhp < 1) done_in_by(mtmp); } void losexp() { /* hit by V or W */ int num; if (u.ulevel > 1) pline("Goodbye level %u.", u.ulevel--); else u.uhp = -1; num = rnd(10); u.uhp -= num; u.uhpmax -= num; u.uexp = newuexp(); flags.botl = 1; } int inv_weight() { struct obj *otmp = invent; int wt = (u.ugold + 500) / 1000; int carrcap; if (Levitation) /* pugh@cornell */ carrcap = MAX_CARR_CAP; else { carrcap = 5 * (((u.ustr > 18) ? 20 : u.ustr) + u.ulevel); if (carrcap > MAX_CARR_CAP) carrcap = MAX_CARR_CAP; if (Wounded_legs & LEFT_SIDE) carrcap -= 10; if (Wounded_legs & RIGHT_SIDE) carrcap -= 10; } while (otmp) { wt += otmp->owt; otmp = otmp->nobj; } return (wt - carrcap); } int inv_cnt() { struct obj *otmp = invent; int ct = 0; while (otmp) { ct++; otmp = otmp->nobj; } return (ct); } long newuexp() { return (10 * (1L << (u.ulevel - 1))); } bsd-games-2.17/hack/rumors0000664000175000017500000006077010032065423014164 0ustar jsm28jsm28"Quit" is a four letter word. "So when I die, the first thing I will see in Heaven is a score list?" -- more -- ...and rings may protect your fingers. ...and sometimes a piercer drops by. A Quasit is even faster than a jaguar! A chameleon imitating a postman often delivers scrolls of fire. A chameleon imitating a postman sometimes delivers scrolls of punishment. A clove of garlic a day keeps your best friends away. A cockatrice's corpse is guaranteed to be untainted! A confused acid blob may attack. A dead lizard is a good thing to turn undead. A dragon is just a Snake that ate a scroll of fire. A fading corridor enlightens your insight. A glowing potion is too hot to drink. A good amulet may protect you against guards. A homunculus wouldnt want to hurt a wizard. A jaguar shouldn't frighten you. A long worm can be defined recursively. So how should you attack it? A long worm hits with all of its length. A magic vomit pump is a necessity for gourmands. A monstrous mind is a toy for ever. A nurse a day keeps the doctor away. A potion of blindness makes you see invisible things. A ring is just a wound wand. A ring of adornment protects against Nymphs. A ring of conflict is a bad thing if there is a nurse in the room. A ring of extra ringfinger is useless if not enchanted. A ring of stealth can be recognised by that it does not teleport you. A rope may form a trail in a maze. A rumour has it that rumours are just rumours. A scroll of enchant amulet is only useful on your way back. A smoky potion surely affects your vision. A spear might hit a nurse. A spear will hit an ettin. A staff may recharge if you drop it for awhile. A tin of smoked eel is a wonderful find. A truly wise man never plays leapfrog with a unicorn. A two-handed sword usually misses. A unicorn can be tamed only by a fair maiden. A visit to the Zoo is very educational; you meet interesting animals. A wand of deaf is a more dangerous weapon than a wand of sheep. A wand of vibration might bring the whole cave crashing about your ears. A winner never quits. A quitter never wins. A xan is a small animal. It doesn't reach higher than your leg. Acid blobs should be attacked bare-handed. Affairs with Nymphs are often very expensive. Afraid of Mimics? Try to wear a ring of true seeing. Afraid of falling piercers? Wear a helmet! After being attacked by a Harpy you have a lot of arrows. All monsters are created evil, but some are more evil than others. Always attack a floating Eye from behind! Always be aware of the phase of the moon! Always read the info about a monster before dealing with it. Always sweep the floor before engraving important messages. Amulets are hard to make. Even for a wand of wishing. An Umber hulk can be a confusing sight. An elven cloak is always the height of fashion. An elven cloak protects against magic. An ettin is hard to kill; an imp is hard to hit. See the difference? Any small object that is accidentally dropped will hide under a larger object. Are you blind? Catch a floating Eye! Asking about monsters may be very useful. Attack long worms from the rear - that is so much safer! Attacking an eel when there is none usually is a fatal mistake! Balrogs only appear on the deeper levels. Be careful when eating bananas. Monsters might slip on the peels. Be careful when eating salmon - your fingers might become greasy. Be careful when the moon is in its last quarter. Be careful when throwing a boomerang - you might hit the back of your head. Be nice to a nurse: put away your weapon and take off your clothes. Being digested is a painfully slow process. Better go home and hit your kids. They are just little monsters! Better go home and play with your kids. They are just little monsters! Better leave the dungeon, otherwise you might get hurt badly. Beware of dark rooms - they may be the Morgue. Beware of death rays! Beware of falling rocks, wear a helmet! Beware of hungry dogs! Beware of the minotaur. He's very horny! Beware of the potion of Nitroglycerine - it's not for the weak of heart. Beware of wands of instant disaster. Beware: there's always a chance that your wand explodes as you try to zap it! Beyond the 23-rd level lies a happy retirement in a room of your own. Blank scrolls make more interesting reading. Blind? Eat a carrot! Booksellers never read scrolls; it might carry them too far away. Booksellers never read scrolls; it might leave their shop unguarded. Changing your suit without dropping your sword? You must be kidding! Cockatrices might turn themselves to stone faced with a mirror. Consumption of home-made food is strictly forbidden in this dungeon. Dark gems are just coloured glass. Dark room? Just flash often with your camera. Dark room? Your chance to develop your photographs! Dark rooms are not *completely* dark: just wait and let your eyes adjust... Dead lizards protect against a cockatrice. Death is just around the next door. Death is life's way of telling you you've been fired. Descend in order to meet more decent monsters. Did you know worms had teeth? Didn't you forget to pay? Didn't you forget to pay? Direct a direct hit on your direct opponent, directing in the right direction. Do something big today: lift a boulder. Do you want to visit hell? Dig a *very* deep hole. Dogs are attracted by the smell of tripe. Dogs do not eat when the moon is full. Dogs never step on cursed items. Dogs of ghosts aren't angry, just hungry. Don't bother about money: only Leprechauns and shopkeepers are interested. Don't create fireballs: they might turn against you. Don't eat too much: you might start hiccoughing! Don't forget! Large dogs are MUCH harder to kill than little dogs. Don't play hack at your work, your boss might hit you! Don't swim with weapons or armour: they might rust! Don't tell a soul you found a secret door, otherwise it isn't secret anymore. Don't throw gems. They are so precious! Besides, you might hit a roommate. Drinking might affect your health. Drop your vanity and get rid of your jewels! Pickpockets about! Dungeon expects every monster to do his duty. Dust is an armor of poor quality. Eat 10 cloves of garlic and keep all humans at a two-square distance. Eat a homunculus if you want to avoid sickness. Eating a Wraith is a rewarding experience! Eating a freezing sphere is like eating a yeti. Eating a killer bee is like eating a scorpion. Eating a tengu is like eating a Nymph. Eating unpaid Leprechauns may be advantageous. Eels hide under mud. Use a unicorn to clear the water and make them visible. Elven cloaks cannot rust. Engrave your wishes with a wand of wishing. Eventually all wands of striking do strike. Eventually you will come to admire the swift elegance of a retreating nymph. Ever fought with an enchanted tooth? Ever heard hissing outside? I *knew* you hadn't! Ever seen a leocrotta dancing the tengu? Ever slept in the arms of a homunculus? Ever tamed a shopkeeper? Ever tried digging through a Vault Guard? Ever tried enchanting a rope? Ever tried to catch a flying boomerang? Ever tried to put a Troll into a large box? Ever wondered why one would want to dip something in a potion? Every dog should be a domesticated one. Every hand has only one finger to put a ring on. You've got only two hands. So? Every level contains a shop; only the entrance is often hidden. Everybody should have tasted a scorpion at least once in his life. Expensive cameras have penetrating flashlights. Feeding the animals is strictly prohibited. The Management. Feeling lousy? Why don't you drink a potion of tea? Fiery letters might deter monsters. First Law of Hacking: leaving is much more difficult than entering. For any remedy there is a misery. Fourth Law of Hacking: you will find the exit at the entrance. Gems are the droppings of other inmates. Gems do get a burden. Genocide on shopkeepers is punishable. Getting Hungry? Stop wearing rings! Getting Hungry? Wear an amulet! Ghosts always empty the fridge. Ghosts are visible because they don't leave a trace. Giant beetles make giant holes in giant trees! Giving head to a long worm is like a long lasting reception. Gold is a heavy metal. Good day for overcoming obstacles. Try a steeplechase. Gossip is the opiate of the depressed. Hackers do it with bugs. Half Moon tonight. (At least it's better than no Moon at all.) Handle your flasks carefully - there might be a ghost inside! Have a good meal today: eat a minotaur. Hey guys, you *WIELD* a dead lizard against a cocatrice! [David London] Hissing is a sound I hate. Hitting is the lingua franca in these regions. Humans use walking canes when they grow old. Hunger is a confusing experience for a dog! Hungry dogs are unreliable. Hungry? There is an abundance of food on the next level. Hungry? Wear an amulet! I doubt whether nurses are virgins. I guess you have never hit a postman with an Amulet of Yendor yet... I once knew a hacker who ate too fast and choked to death..... I smell a maze of twisty little passages. I wished, I never wished a wand of wishing. (Wishful thinking) If "nothing happens", something *has* happened anyway!! If a chameleon mimics a mace, it really mimics a Mimic mimicking a mace. If a shopkeeper kicks you out of his shop, he'll kick you out of the dungeon. If you are being punished, it's done with a deadly weapon. If you are the shopkeeper you can take things for free. If you are too cute some monsters might be tempted to embrace you. If you can't learn to do it well, learn to enjoy doing it badly. If you need a wand of digging, kindly ask the minotaur. If you see nurses you better start looking somewhere for a doctor. If you turn blind: don't expect your dog to be turned into a seeing-eye dog. If you want to feel great, you must eat something real big. If you want to float you'd better eat a floating eye. If you want to genocide nurses, genocide @'s. If you want to hit, use a dagger. If you want to rob a shop, train your dog. If you're afraid of trapdoors, just cover the floor with all you've got. If you're lost, try buying a map next time you're in a shop. If your ghost kills a player, it increases your score. Important mail? Be careful that it isn't stolen! Improve your environment, using a wand of rearrangement. In a hurry? Try a ride on a fast moving quasit! In a way, a scorpion is like a snake. In need of a rest? Quaff a potion of sickness! In total, there are eight sorts of shops. Increase mindpower: Tame your own ghost! Inside a shop you better take a look at the price tags before buying anything. It furthers one to see the great man. It is bad manners to use a wand in a shop. It is not always a good idea to whistle for your dog. It is said that Giant Rabbits can be tamed with carrots only. It is said that purple worms and trappers fill the same niche. It might be a good idea to offer the unicorn a ruby. It seems you keep overlooking a sign reading "No trespassing"! It would be peculiarly sad were your dog turned to stone. It's all a matter of life and death, so beware of the undead. It's bad luck to drown a postman. It's bad luck, being punished. It's easy to overlook a monster in a wood. It's not safe to Save. Jackals are intrinsically rotten. Just below any trapdoor there may be another one. Just keep falling! Keep a clear mind: quaff clear potions. Keep your armours away from rust. Keep your weaponry away from acids. Kicking the terminal doesn't hurt the monsters. Kill a unicorn and you kill your luck. Killer bees keep appearing till you kill their queen. Large dogs make larger turds than little ones. Latest news? Put 'net.games.hack' in your .newsrc ! Latest news? Put newsgroup 'netUNX.indoor.hackers-scroll' in your .newsrc! Learn how to spell. Play Hack! Leather armour cannot rust. Leprechauns are the most skilled cutpurses in this dungeon. Leprechauns hide their gold in a secret room. Let your fingers do the walking on the yulkjhnb keys. Let's face it: this time you're not going to win. Let's have a party, drink a lot of booze. Liquor sellers do not drink; they hate to see you twice. Looking for a monster -- use a staff of monster summoning. Looking pale? Quaff a red potion! M.M.Vault cashiers teleport any amount of gold to the next local branch. Many monsters make a murdering mob. Meet yourself! Commit suicide and type "hack" Meeting your own ghost decreases your luck considerably! Memory flaw - core dumped. Money is the root of all evil. Money to invest? Take it to the local branch of the Magic Memory Vault! Monsters come from nowhere to hit you everywhere. Monsters sleep because you are boring, not because they ever get tired. Most monsters can't swim. Most monsters prefer minced meat. That's why they are hitting you! Most rumors are just as misleading as this one. Much ado Nothing Happens. Murder complaint? Mail to 'netnix!devil!gamble!freak!trap!lastwill!rip'. Need money? Sell your corpses to a tin factory. Never ask a shopkeeper for a price list. Never attack a guard. Never drop a crysknife! No, never even unwield it, until... Never eat with glowing hands! Never fight a monster: you might get killed. Never go into the dungeon at midnight. Never kick a sleeping dog. Never kiss an animal. It may cause kissing disease. Never map the labyrinth. Never mind the monsters hitting you: they just replace the charwomen. Never ride a long worm. Never step on a cursed engraving. Never swim with a camera: there's nothing to take pictures of. Never trust a random generator in magic fields. Never use a wand of death. Never use your best weapon to engrave a curse. Never vomit on a door mat. No easy fighting with a heavy load! No level contains two shops. The maze is no level. So... No part of this fortune may be reproduced, stored in a retrieval system, ... No weapon is better than a crysknife. Not all rumors are as misleading as this one. Not even a spear will hit a Xorn. Now what is it that cures digestion? Nurses are accustomed to touch naked persons: they don't harm them. Nurses prefer undressed hackers. Nymphs and nurses like beautiful rings. Nymphs are blondes. Are you a gentleman? Nymphs are very pleased when you call them by their real name: Lorelei. Offering a unicorn a worthless piece of glass might prove to be fatal! Old hackers never die: young ones do. Old trees sometimes fall without a warning! Once your little dog will be a big dog, and you will be proud of it. One can even choke in a fortune cookie! One has to leave shops before closing time. One homunculus a day keeps the doctor away. One level further down somebody is getting killed, right now. One wand of concentration equals eight scrolls of create monster. Only Today! A dramatic price-cut on slightly used wands. Only a Nymph knows how to unlock chains. Only a dragon will never get a cold from a wand of cold. Only a real dummy would ever call his sword 'Elbereth'. Only a wizard can use a magic whistle. Only adventurers of evil alignment think of killing their dog. Only cave-women can catch a unicorn. And then only with a golden rope. Only chaotic evils kill sleeping monsters. Only david can find the zoo! Only real trappers escape traps. Only real wizards can write scrolls. Only wizards are able to zap a wand. Opening a tin is difficult, especially when you are not so strong! Opening a tin is difficult, especially when you attempt this bare handed! Operation coded OVERKILL has started now. Orcs and killer bees share their lifestyle. Orcs do not procreate in dark rooms. PLEASE ignore previous rumour. Plain nymphs are harmless. Playing billiards pays when you are in a shop. Polymorphing your dog probably makes you safer. Praying will frighten Demons. Punishment is a thing you call over yourself. So why complain? Pursue the monsters and you will be had indeed. Put on a ring of teleportation: it will take you away from onslaught. Rays aren't boomerangs, of course, but still... Read the manual before entering the cave - You might get killed otherwise. Reading Herbert will disgust you, but in one case it might be enlightening. Reading Tolkien might help you. Reading might change your vision. Reading might improve your scope. Relying on a dog might turn you in a dog addict. Reward your doggie with a giant Bat. Ropes are made from the long, blond hairs of dead Nymphs. Row (3x) that boat gently down the stream, Charon (4x), death is but a dream. Running is good for your legs. Rust monsters love water. There are potions they hate, however. Savings do include amnesia. Scorpions often hide under tripe rations. Screw up your courage! You've screwed up everything else. Scrolls of fire are useful against fog clouds. Second Law of Hacking: first in, first out. Selling and rebuying a wand will recharge it. Shopkeepers accept creditcards, as long as you pay cash. Shopkeepers are vegetarians: they only eat Swedes. Shopkeepers can't read, so what use is engraving in a shop? Shopkeepers can't swim. Shopkeepers have incredible patience. Shopkeepers often have strange names. Shopkeepers sometimes die from old age. Sleeping may increase your strength. Snakes are often found under worthless objects. Some Balrogs don't attack if you offer them a ring. Some mazes (especially small ones) have no solutions, says man 6 maze. Some monsters can be tamed. I once saw a hacker with a tame Dragon! Some potions are quite mind-expanding. Some questions Sphynxes ask just *don't* have any answers. Sometimes "mu" is the answer. Sometimes monsters are more likely to fight each other than attack you. Sorry, no fortune this time. Better luck next cookie! Spare your scrolls of make-edible until it's really necessary! Speed Kills (The Doors) Spinach, carrot, and a melon - a meal fit for a nurse! Stay clear of the level of no return. Suddenly the dungeon will collapse ... Surprise your dog with an acid blob! Tainted meat is even more sickening than poison! Take a long worm from the rear, according to its mate it's a lot more fun. Tame a troll and it will learn you fighting. Taming a postman may cause a system security violation. Taming is a gradual process of excercising and rewarding. Telepathy is just a trick: once you know how to do it, it's easy. Teleportation lessens your orientation. The "pray" command is not yet implemented. The Jackal only eats bad food. The Leprechaun Gold Tru$t is no division of the Magic Memory Vault. The Leprechauns hide their treasure in a small hidden room. The air is positively magic in here. Better wear a negative armor. The best equipment for your work is, of course, the most expensive. The emptiness of a ghost is too heavy to bear. The key to this game is that there are no keys. The longer the wand the better. The moon is not the only heavenly body to influence this game. The postman always rings twice. The proof of the quivering blob is in the eating thereof. The secret of wands of Nothing Happens: try again! The use of dynamite is dangerous. There are better information sources than fortune cookies. There are monsters of softening penetration. There are monsters of striking charity. There have been people like you in here; their ghosts seek revenge on you. There is a VIP-lounge on this level. Only first-class travellers admitted. There is a big treasure hidden in the zoo! There is a message concealed in each fortune cookie. There is a trap on this level! There is more magic in this cave than meets the eye. There is no business like throw business. There is no harm in praising a large dog. There is nothing like eating a Mimic. There seem to be monsters of touching benevolence. They say a gelatinous cube can paralyse you... They say that Elven cloaks absorb enchantments. They say that a dagger hits. They say that a dog avoids traps. They say that a dog can be trained to fetch objects. They say that a dog never steps on a cursed object. They say that a spear will hit a Dragon. They say that a spear will hit a Xorn. They say that a spear will hit a neo-otyugh. (Do YOU know what that is?) They say that a spear will hit an ettin. They say that a two-handed sword misses. They say that a unicorn might bring you luck. They say that an elven cloak may be worn over your armor. They say that an elven cloak protects against magic. They say that cavemen seldom find tins in the dungeon. They say that dead lizards protect against a cockatrice. They say that killing a shopkeeper brings bad luck. They say that monsters never step on a scare monster scroll. They say that only david can find the zoo! They say that shopkeepers often have a large amount of money in their purse. They say that the owner of the dungeon might change it slightly. They say that the use of dynamite is dangerous. They say that the walls in shops are made of extra hard material. They say that there is a big treasure hidden in the zoo! They say that there is a message concealed in each fortune cookie. They say that there is a trap on this level! They say that throwing food at a wild dog might tame him. They say that you can meet old friends in the caves. They say that you can't take your pick-axe into a shop. They say that you cannot trust scrolls of rumour. They say that you need a key in order to open locked doors. Third Law of Hacking: the last blow counts most. This dungeon is restroom equipped (for your convenience). This fortune cookie is property of Fortune Cookies, Inc. This is not a fortune. This is the Leprechaun Law: every purse has a price. Throwing food at a wild dog might tame him. Tin openers are rare indeed. Tired of irritating bats? Try a scroll of silence. To hit or not to hit, that is the question. To reach heaven, escape the dungeon while wearing a ring of levitation. Tranquillizers might get you killed. Travel fast, use some magic speed! Tripe on its own is revolting, but with onions it's delicious! Try hacking in the wee hours: you will have more room. Try the fall back end run play against ghosts. Ulch, that meat was painted. Unwanted mail? Sell it to the bookshop! Vampires hate garlic. Vault guards always make sure you aren't a shopkeeper. Vault guards never disturb their Lords. Visitors are requested not to apply genocide to shopkeepers. WARNING from H.M. Govt: Quaffing may be dangerous to your health. Wanna fly? Eat a bat. Want a hint? Zap a wand of make invisible on your weapon! Want fun? Throw a potion in a pool and go swimming! Want to conserve your dead corpses? Go to the tin factory! Wanted: shopkeepers. Send a scroll of mail to: Mage of Yendor/Level 35/Dungeon. Warning: end of file 'fortunes' reached. Warning: people who eat dragons can go to hell!! Watch your steps on staircases. Wear armor, going naked seems to offend public decency in here. What a pity, you cannot read it! What do you think is the use of dead lizards? What do you think would be the use of a two handed sword called "Orcrist" ? When a piercer drops in on you, you will be tempted to hit the ceiling! When in a maze follow the right wall and you will never get lost. When in a shop, do as shopkeepers do. When punished, watch your steps on the stairs! When you have a key, you don't have to wait for the guard. When you have seen one killer bee, you have seen them all. When your dog follows you through a trap door, don't hit it! Where do you think all those demons come from? From Hell, of course. Where do you think the hell is located? It must be deep, deep down. Who should ever have thought one could live from eating fog clouds? Why a "2" for the postman? Well, how many times does he ring? Why should one ever throw an egg to a cockatrice? Why would anybody in his sane mind engrave "Elbereth" ? Wish for a master key and open the Magic Memory Vault! Wish for a pass-key and pass all obstacles! Wish for a skeleton-key and open all doors! Wishing too much may bring you too little. Wizards do not sleep. You are heading for head-stone for sure. You are just the kind of bad food some monsters like to digest. You can always wear an elven cloak. You can eat what your dog can eat. You can get a genuine Amulet of Yendor by doing the following: -- more -- You can't get rid of a cursed plate mail with a can-opener. You can't leave a shop through the back door: there ain't one! You cannot ride a long worm. You cannot trust scrolls of rumour. You die... You feel greedy and want more gold? Why don't you try digging? You feel like someone is pulling your leg. You have to outwit a Sphynx or pay her. You may get rich selling letters, but beware of being blackmailed! You may have a kick from kicking a little dog. You might choke on your food by eating fortune cookies. You might cut yourself on a long sword. You might trick a shopkeeper if you're invisible. You need a key in order to open locked doors. You offend Shai-Hulud by sheathing your crysknife without having drawn blood. You want to regain strength? Two levels ahead is a guesthouse! You'll need a spear if you want to attack a Dragon. You've got to know how to put out a yellow light. Your dog can buy cheaper than you do. Zapping a wand of Nothing Happens doesn't harm you a bit. Zapping a wand of undead turning might bring your dog back to life. bsd-games-2.17/hack/hack.do_name.c0000664000175000017500000002253307767741711015406 0ustar jsm28jsm28/* $NetBSD: hack.do_name.c,v 1.6 2003/04/02 18:36:36 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.do_name.c,v 1.6 2003/04/02 18:36:36 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" coord getpos(force, goal) int force; const char *goal; { int cx, cy, i, c; coord cc; pline("(For instructions type a ?)"); cx = u.ux; cy = u.uy; curs(cx, cy + 2); while ((c = readchar()) != '.') { for (i = 0; i < 8; i++) if (sdir[i] == c) { if (1 <= cx + xdir[i] && cx + xdir[i] <= COLNO) cx += xdir[i]; if (0 <= cy + ydir[i] && cy + ydir[i] <= ROWNO - 1) cy += ydir[i]; goto nxtc; } if (c == '?') { pline("Use [hjkl] to move the cursor to %s.", goal); pline("Type a . when you are at the right place."); } else { pline("Unknown direction: '%s' (%s).", visctrl(c), force ? "use hjkl or ." : "aborted"); if (force) goto nxtc; cc.x = -1; cc.y = 0; return (cc); } nxtc: ; curs(cx, cy + 2); } cc.x = cx; cc.y = cy; return (cc); } int do_mname() { char buf[BUFSZ]; coord cc; int cx, cy, lth, i; struct monst *mtmp, *mtmp2; cc = getpos(0, "the monster you want to name"); cx = cc.x; cy = cc.y; if (cx < 0) return (0); mtmp = m_at(cx, cy); if (!mtmp) { if (cx == u.ux && cy == u.uy) pline("This ugly monster is called %s and cannot be renamed.", plname); else pline("There is no monster there."); return (1); } if (mtmp->mimic) { pline("I see no monster there."); return (1); } if (!cansee(cx, cy)) { pline("I cannot see a monster there."); return (1); } pline("What do you want to call %s? ", lmonnam(mtmp)); getlin(buf); clrlin(); if (!*buf || *buf == '\033') return (1); lth = strlen(buf) + 1; if (lth > 63) { buf[62] = 0; lth = 63; } mtmp2 = newmonst(mtmp->mxlth + lth); *mtmp2 = *mtmp; for (i = 0; (unsigned)i < mtmp->mxlth; i++) ((char *) mtmp2->mextra)[i] = ((char *) mtmp->mextra)[i]; mtmp2->mnamelth = lth; (void) strcpy(NAME(mtmp2), buf); replmon(mtmp, mtmp2); return (1); } /* * This routine changes the address of obj . Be careful not to call it * when there might be pointers around in unknown places. For now: only * when obj is in the inventory. */ void do_oname(obj) struct obj *obj; { struct obj *otmp, *otmp2; int lth; char buf[BUFSZ]; pline("What do you want to name %s? ", doname(obj)); getlin(buf); clrlin(); if (!*buf || *buf == '\033') return; lth = strlen(buf) + 1; if (lth > 63) { buf[62] = 0; lth = 63; } otmp2 = newobj(lth); *otmp2 = *obj; otmp2->onamelth = lth; (void) strcpy(ONAME(otmp2), buf); setworn((struct obj *) 0, obj->owornmask); setworn(otmp2, otmp2->owornmask); /* * do freeinv(obj); etc. by hand in order to preserve the position of * this object in the inventory */ if (obj == invent) invent = otmp2; else for (otmp = invent;; otmp = otmp->nobj) { if (!otmp) panic("Do_oname: cannot find obj."); if (otmp->nobj == obj) { otmp->nobj = otmp2; break; } } #if 0 obfree(obj, otmp2); /* now unnecessary: no pointers on bill */ #endif free((char *) obj); /* let us hope nobody else saved a pointer */ } int ddocall() { struct obj *obj; pline("Do you want to name an individual object? [ny] "); switch (readchar()) { case '\033': break; case 'y': obj = getobj("#", "name"); if (obj) do_oname(obj); break; default: obj = getobj("?!=/", "call"); if (obj) docall(obj); } return (0); } void docall(obj) struct obj *obj; { char buf[BUFSZ]; struct obj otemp; char **str1; char *str; otemp = *obj; otemp.quan = 1; otemp.onamelth = 0; str = xname(&otemp); pline("Call %s %s: ", strchr(vowels, *str) ? "an" : "a", str); getlin(buf); clrlin(); if (!*buf || *buf == '\033') return; str = newstring(strlen(buf) + 1); (void) strcpy(str, buf); str1 = &(objects[obj->otyp].oc_uname); if (*str1) free(*str1); *str1 = str; } const char *const ghostnames[] = {/* these names should have length < PL_NSIZ */ "adri", "andries", "andreas", "bert", "david", "dirk", "emile", "frans", "fred", "greg", "hether", "jay", "john", "jon", "kay", "kenny", "maud", "michiel", "mike", "peter", "robert", "ron", "tom", "wilmar" }; char * xmonnam(mtmp, vb) struct monst *mtmp; int vb; { static char buf[BUFSZ]; /* %% */ if (mtmp->mnamelth && !vb) { (void) strcpy(buf, NAME(mtmp)); return (buf); } switch (mtmp->data->mlet) { case ' ': { const char *gn = (char *) mtmp->mextra; if (!*gn) { /* might also look in scorefile */ gn = ghostnames[rn2(SIZE(ghostnames))]; if (!rn2(2)) (void) strcpy((char *) mtmp->mextra, !rn2(5) ? plname : gn); } (void) sprintf(buf, "%s's ghost", gn); } break; case '@': if (mtmp->isshk) { (void) strcpy(buf, shkname(mtmp)); break; } /* fall into next case */ default: (void) sprintf(buf, "the %s%s", mtmp->minvis ? "invisible " : "", mtmp->data->mname); } if (vb && mtmp->mnamelth) { (void) strcat(buf, " called "); (void) strcat(buf, NAME(mtmp)); } return (buf); } char * lmonnam(mtmp) struct monst *mtmp; { return (xmonnam(mtmp, 1)); } char * monnam(mtmp) struct monst *mtmp; { return (xmonnam(mtmp, 0)); } char * Monnam(mtmp) struct monst *mtmp; { char *bp = monnam(mtmp); if ('a' <= *bp && *bp <= 'z') *bp += ('A' - 'a'); return (bp); } char * amonnam(mtmp, adj) struct monst *mtmp; const char *adj; { char *bp = monnam(mtmp); static char buf[BUFSZ]; /* %% */ if (!strncmp(bp, "the ", 4)) bp += 4; (void) sprintf(buf, "the %s %s", adj, bp); return (buf); } char * Amonnam(mtmp, adj) struct monst *mtmp; const char *adj; { char *bp = amonnam(mtmp, adj); *bp = 'T'; return (bp); } char * Xmonnam(mtmp) struct monst *mtmp; { char *bp = Monnam(mtmp); if (!strncmp(bp, "The ", 4)) { bp += 2; *bp = 'A'; } return (bp); } char * visctrl(c) char c; { static char ccc[3]; if (c < 040) { ccc[0] = '^'; ccc[1] = c + 0100; ccc[2] = 0; } else { ccc[0] = c; ccc[1] = 0; } return (ccc); } bsd-games-2.17/hack/hack.cmd.c0000664000175000017500000002165507767741711014553 0ustar jsm28jsm28/* $NetBSD: hack.cmd.c,v 1.7 2003/04/02 18:36:35 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.cmd.c,v 1.7 2003/04/02 18:36:35 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #include "def.func_tab.h" const struct func_tab cmdlist[] = { { '\020', doredotopl }, { '\022', doredraw }, { '\024', dotele }, #ifdef SUSPEND { '\032', dosuspend }, #endif /* SUSPEND */ { 'a', doapply }, /* 'A' : UNUSED */ /* 'b', 'B' : go sw */ { 'c', ddocall }, { 'C', do_mname }, { 'd', dodrop }, { 'D', doddrop }, { 'e', doeat }, { 'E', doengrave }, /* 'f', 'F' : multiple go (might become 'fight') */ /* 'g', 'G' : UNUSED */ /* 'h', 'H' : go west */ { 'I', dotypeinv }, /* Robert Viduya */ { 'i', ddoinv }, /* 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' : move commands */ /* 'o', doopen, */ { 'O', doset }, { 'p', dopay }, { 'P', dowearring }, { 'q', dodrink }, { 'Q', dodone }, { 'r', doread }, { 'R', doremring }, { 's', dosearch }, { 'S', dosave }, { 't', dothrow }, { 'T', doremarm }, /* 'u', 'U' : go ne */ { 'v', doversion }, /* 'V' : UNUSED */ { 'w', dowield }, { 'W', doweararm }, /* 'x', 'X' : UNUSED */ /* 'y', 'Y' : go nw */ { 'z', dozap }, /* 'Z' : UNUSED */ { '<', doup }, { '>', dodown }, { '/', dowhatis }, { '?', dohelp }, #ifdef SHELL { '!', dosh }, #endif /* SHELL */ { '.', donull }, { ' ', donull }, { ',', dopickup }, { ':', dolook }, { '^', doidtrap }, { '\\', dodiscovered }, /* Robert Viduya */ { WEAPON_SYM, doprwep }, { ARMOR_SYM, doprarm }, { RING_SYM, doprring }, { '$', doprgold }, { '#', doextcmd }, { 0, 0 } }; const struct ext_func_tab extcmdlist[] = { { "dip", dodip }, { "pray", dopray }, { (char *) 0, donull } }; void rhack(cmd) const char *cmd; { const struct func_tab *tlist = cmdlist; boolean firsttime = FALSE; int res; if (!cmd) { firsttime = TRUE; flags.nopick = 0; cmd = parse(); } if (!*cmd || (*cmd & 0377) == 0377 || (flags.no_rest_on_space && *cmd == ' ')) { bell(); flags.move = 0; return; /* probably we just had an interrupt */ } if (movecmd(*cmd)) { walk: if (multi) flags.mv = 1; domove(); return; } if (movecmd(lowc(*cmd))) { flags.run = 1; rush: if (firsttime) { if (!multi) multi = COLNO; u.last_str_turn = 0; } flags.mv = 1; #ifdef QUEST if (flags.run >= 4) finddir(); if (firsttime) { u.ux0 = u.ux + u.dx; u.uy0 = u.uy + u.dy; } #endif /* QUEST */ domove(); return; } if ((*cmd == 'f' && movecmd(cmd[1])) || movecmd(unctrl(*cmd))) { flags.run = 2; goto rush; } if (*cmd == 'F' && movecmd(lowc(cmd[1]))) { flags.run = 3; goto rush; } if (*cmd == 'm' && movecmd(cmd[1])) { flags.run = 0; flags.nopick = 1; goto walk; } if (*cmd == 'M' && movecmd(lowc(cmd[1]))) { flags.run = 1; flags.nopick = 1; goto rush; } #ifdef QUEST if (*cmd == cmd[1] && (*cmd == 'f' || *cmd == 'F')) { flags.run = 4; if (*cmd == 'F') flags.run += 2; if (cmd[2] == '-') flags.run += 1; goto rush; } #endif /* QUEST */ while (tlist->f_char) { if (*cmd == tlist->f_char) { res = (*(tlist->f_funct)) (); if (!res) { flags.move = 0; multi = 0; } return; } tlist++; } { char expcmd[10]; char *cp = expcmd; while (*cmd && cp - expcmd < (int)sizeof(expcmd) - 2) { if (*cmd >= 040 && *cmd < 0177) *cp++ = *cmd++; else { *cp++ = '^'; *cp++ = *cmd++ ^ 0100; } } *cp++ = 0; pline("Unknown command '%s'.", expcmd); } multi = flags.move = 0; } int doextcmd() { /* here after # - now read a full-word * command */ char buf[BUFSZ]; const struct ext_func_tab *efp = extcmdlist; pline("# "); getlin(buf); clrlin(); if (buf[0] == '\033') return (0); while (efp->ef_txt) { if (!strcmp(efp->ef_txt, buf)) return ((*(efp->ef_funct)) ()); efp++; } pline("%s: unknown command.", buf); return (0); } char lowc(sym) char sym; { return ((sym >= 'A' && sym <= 'Z') ? sym + 'a' - 'A' : sym); } char unctrl(sym) char sym; { return ((sym >= ('A' & 037) && sym <= ('Z' & 037)) ? sym + 0140 : sym); } /* 'rogue'-like direction commands */ char sdir[] = "hykulnjb><"; schar xdir[10] = {-1, -1, 0, 1, 1, 1, 0, -1, 0, 0}; schar ydir[10] = {0, -1, -1, -1, 0, 1, 1, 1, 0, 0}; schar zdir[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, -1}; int movecmd(sym) /* also sets u.dz, but returns false for <> */ char sym; { char *dp; u.dz = 0; if (!(dp = strchr(sdir, sym))) return (0); u.dx = xdir[dp - sdir]; u.dy = ydir[dp - sdir]; u.dz = zdir[dp - sdir]; return (!u.dz); } int getdir(s) boolean s; { char dirsym; if (s) pline("In what direction?"); dirsym = readchar(); if (!movecmd(dirsym) && !u.dz) { if (!strchr(quitchars, dirsym)) pline("What a strange direction!"); return (0); } if (Confusion && !u.dz) confdir(); return (1); } void confdir() { int x = rn2(8); u.dx = xdir[x]; u.dy = ydir[x]; } #ifdef QUEST int finddir() { int i, ui = u.di; for (i = 0; i <= 8; i++) { if (flags.run & 1) ui++; else ui += 7; ui %= 8; if (i == 8) { pline("Not near a wall."); flags.move = multi = 0; return (0); } if (!isroom(u.ux + xdir[ui], u.uy + ydir[ui])) break; } for (i = 0; i <= 8; i++) { if (flags.run & 1) ui += 7; else ui++; ui %= 8; if (i == 8) { pline("Not near a room."); flags.move = multi = 0; return (0); } if (isroom(u.ux + xdir[ui], u.uy + ydir[ui])) break; } u.di = ui; u.dx = xdir[ui]; u.dy = ydir[ui]; return 0; } int isroom(x, y) int x, y; { /* what about POOL? */ return (isok(x, y) && (levl[x][y].typ == ROOM || (levl[x][y].typ >= LDOOR && flags.run >= 6))); } #endif /* QUEST */ int isok(x, y) int x, y; { /* x corresponds to curx, so x==1 is the first column. Ach. %% */ return (x >= 1 && x <= COLNO - 1 && y >= 0 && y <= ROWNO - 1); } bsd-games-2.17/hack/OWNER0000664000175000017500000000003207077410364013525 0ustar jsm28jsm28Andries Brouwer mcvax!aeb bsd-games-2.17/hack/hack.h0000664000175000017500000002133710005547567014003 0ustar jsm28jsm28/* $NetBSD: hack.h,v 1.10 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _HACK_H_ #define _HACK_H_ #include "config.h" #include #include #ifndef BSD #define index strchr #define rindex strrchr #endif /* BSD */ #define Null(type) ((struct type *) 0) #include "def.objclass.h" typedef struct { xchar x,y; } coord; #include "def.monst.h" /* uses coord */ #include "def.gold.h" #include "def.trap.h" #include "def.obj.h" #include "def.flag.h" #define plur(x) (((x) == 1) ? "" : "s") #define BUFSZ 256 /* for getlin buffers */ #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */ #include "def.rm.h" #include "def.permonst.h" #define newstring(x) (char *) alloc((unsigned)(x)) #include "hack.onames.h" #define ON 1 #define OFF 0 struct prop { #define TIMEOUT 007777 /* mask */ #define LEFT_RING W_RINGL /* 010000L */ #define RIGHT_RING W_RINGR /* 020000L */ #define INTRINSIC 040000L #define LEFT_SIDE LEFT_RING #define RIGHT_SIDE RIGHT_RING #define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE) long p_flgs; void (*p_tofn)(void); /* called after timeout */ }; struct you { xchar ux, uy; schar dx, dy, dz; /* direction of move (or zap or ... ) */ #ifdef QUEST schar di; /* direction of FF */ xchar ux0, uy0; /* initial position FF */ #endif /* QUEST */ xchar udisx, udisy; /* last display pos */ char usym; /* usually '@' */ schar uluck; #define LUCKMAX 10 /* on moonlit nights 11 */ #define LUCKMIN (-10) int last_str_turn:3; /* 0: none, 1: half turn, 2: full turn */ /* +: turn right, -: turn left */ unsigned udispl:1; /* @ on display */ unsigned ulevel:4; /* 1 - 14 */ #ifdef QUEST unsigned uhorizon:7; #endif /* QUEST */ unsigned utrap:3; /* trap timeout */ unsigned utraptype:1; /* defined if utrap nonzero */ #define TT_BEARTRAP 0 #define TT_PIT 1 unsigned uinshop:6; /* used only in shk.c - (roomno+1) of shop */ /* perhaps these #define's should also be generated by makedefs */ #define TELEPAT LAST_RING /* not a ring */ #define Telepat u.uprops[TELEPAT].p_flgs #define FAST (LAST_RING+1) /* not a ring */ #define Fast u.uprops[FAST].p_flgs #define CONFUSION (LAST_RING+2) /* not a ring */ #define Confusion u.uprops[CONFUSION].p_flgs #define INVIS (LAST_RING+3) /* not a ring */ #define Invis u.uprops[INVIS].p_flgs #define Invisible (Invis && !See_invisible) #define GLIB (LAST_RING+4) /* not a ring */ #define Glib u.uprops[GLIB].p_flgs #define PUNISHED (LAST_RING+5) /* not a ring */ #define Punished u.uprops[PUNISHED].p_flgs #define SICK (LAST_RING+6) /* not a ring */ #define Sick u.uprops[SICK].p_flgs #define BLIND (LAST_RING+7) /* not a ring */ #define Blind u.uprops[BLIND].p_flgs #define WOUNDED_LEGS (LAST_RING+8) /* not a ring */ #define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs #define STONED (LAST_RING+9) /* not a ring */ #define Stoned u.uprops[STONED].p_flgs #define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */ unsigned umconf:1; const char *usick_cause; struct prop uprops[LAST_RING+10]; unsigned uswallow:1; /* set if swallowed by a monster */ unsigned uswldtim:4; /* time you have been swallowed */ unsigned uhs:3; /* hunger state - see hack.eat.c */ schar ustr,ustrmax; schar udaminc; schar uac; int uhp,uhpmax; long int ugold,ugold0,uexp,urexp; int uhunger; /* refd only in eat.c and shk.c */ int uinvault; struct monst *ustuck; int nr_killed[CMNUM+2]; /* used for experience bookkeeping */ }; #define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2))) #define PL_CSIZ 20 /* sizeof pl_character */ #define MAX_CARR_CAP 120 /* so that boulders can be heavier */ #define MAXLEVEL 40 #define FAR (COLNO+2) /* position outside screen */ extern boolean in_mklev; extern boolean level_exists[]; extern boolean restoring; extern char *CD; extern const char *catmore; extern char *hname; extern const char *const hu_stat[]; /* in eat.c */ extern const char *nomovemsg; extern const char *occtxt; extern char *save_cm; extern const char *killer; extern const char *const traps[]; extern char SAVEF[]; extern char fut_geno[60]; /* idem */ extern char genocided[60]; /* defined in Decl.c */ extern char lock[]; extern char mlarge[]; extern char morc; extern char nul[]; extern char plname[PL_NSIZ], pl_character[PL_CSIZ]; extern const char quitchars[]; extern char sdir[]; /* defined in hack.c */ extern const char shtypes[]; /* = "=/)%?!["; 8 types: 7 specialized, 1 mixed */ extern const char vowels[]; extern coord bhitpos; /* place where thrown weapon falls to the ground */ extern int (*afternmv)(void); extern int (*occupation)(void); extern int CO, LI; /* usually COLNO and ROWNO+2 */ extern int bases[]; extern int doorindex; extern int hackpid; extern int multi; extern int nroom; extern long moves; extern long wailmsg; extern schar xdir[], ydir[]; /* idem */ extern struct monst *mydogs; extern struct monst youmonst; extern struct obj *billobjs; extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg; extern struct obj *uleft, *uright, *fcobj; extern struct obj *uball; /* defined if PUNISHED */ extern struct obj *uchain; /* defined iff PUNISHED */ extern struct obj zeroobj; extern const struct permonst li_dog, dog, la_dog; extern const struct permonst pm_eel; extern const struct permonst pm_ghost; extern const struct permonst pm_mail_daemon; extern const struct permonst pm_wizard; #ifndef NOWORM extern long wgrowtime[32]; extern struct wseg *m_atseg; extern struct wseg *wsegs[32], *wheads[32]; #endif extern struct you u; extern xchar curx, cury; /* cursor location on screen */ extern xchar dlevel, maxdlevel; /* dungeon level */ extern xchar seehx,seelx,seehy,seely; /* where to see*/ extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */ #endif /* _HACK_H_ */ bsd-games-2.17/hack/def.obj.h0000664000175000017500000001077407767741711014417 0ustar jsm28jsm28/* $NetBSD: def.obj.h,v 1.5 2003/04/02 18:36:34 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_OBJ_H_ #define _DEF_OBJ_H_ struct obj { struct obj *nobj; unsigned o_id; unsigned o_cnt_id; /* id of container object is in */ xchar ox,oy; xchar odx,ody; uchar otyp; uchar owt; uchar quan; /* use oextra for tmp gold objects */ schar spe; /* quality of weapon, armor or ring (+ or -) number of charges for wand ( >= -1 ) special for uball and amulet %% BAH */ char olet; char invlet; Bitfield(oinvis,1); /* not yet implemented */ Bitfield(odispl,1); Bitfield(known,1); /* exact nature known */ Bitfield(dknown,1); /* color or text known */ Bitfield(cursed,1); Bitfield(unpaid,1); /* on some bill */ Bitfield(rustfree,1); Bitfield(onamelth,6); long age; /* creation date */ long owornmask; #define W_ARM 01L #define W_ARM2 02L #define W_ARMH 04L #define W_ARMS 010L #define W_ARMG 020L #define W_ARMOR (W_ARM | W_ARM2 | W_ARMH | W_ARMS | W_ARMG) #define W_RINGL 010000L /* make W_RINGL = RING_LEFT (see uprop) */ #define W_RINGR 020000L #define W_RING (W_RINGL | W_RINGR) #define W_WEP 01000L #define W_BALL 02000L #define W_CHAIN 04000L long oextra[1]; /* used for name of ordinary objects - length is flexible; amount for tmp gold objects */ }; extern struct obj *fobj; #define newobj(xl) (struct obj *) alloc((unsigned)(xl) + sizeof(struct obj)) #define ONAME(otmp) ((char *) otmp->oextra) #define OGOLD(otmp) (otmp->oextra[0]) #endif /* _DEF_OBJ_H_ */ bsd-games-2.17/hack/hack.eat.c0000664000175000017500000003313607767741711014556 0ustar jsm28jsm28/* $NetBSD: hack.eat.c,v 1.6 2003/04/02 18:36:36 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.eat.c,v 1.6 2003/04/02 18:36:36 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" char POISONOUS[] = "ADKSVabhks"; /* hunger texts used on bottom line (each 8 chars long) */ #define SATIATED 0 #define NOT_HUNGRY 1 #define HUNGRY 2 #define WEAK 3 #define FAINTING 4 #define FAINTED 5 #define STARVED 6 const char *const hu_stat[] = { "Satiated", " ", "Hungry ", "Weak ", "Fainting", "Fainted ", "Starved " }; void init_uhunger() { u.uhunger = 900; u.uhs = NOT_HUNGRY; } #define TTSZ SIZE(tintxts) const struct { const char *txt; int nut; } tintxts[] = { { "It contains first quality peaches - what a surprise!", 40 }, { "It contains salmon - not bad!", 60 }, { "It contains apple juice - perhaps not what you hoped for.", 20 }, { "It contains some nondescript substance, tasting awfully.", 500 }, { "It contains rotten meat. You vomit.", -50 }, { "It turns out to be empty.", 0 } }; static struct { struct obj *tin; int usedtime, reqtime; } tin; int opentin() { int r; if (!carried(tin.tin)) /* perhaps it was stolen? */ return (0); /* %% probably we should use tinoid */ if (tin.usedtime++ >= 50) { pline("You give up your attempt to open the tin."); return (0); } if (tin.usedtime < tin.reqtime) return (1); /* still busy */ pline("You succeed in opening the tin."); useup(tin.tin); r = rn2(2 * TTSZ); if (r < TTSZ) { pline(tintxts[r].txt); lesshungry(tintxts[r].nut); if (r == 1) { /* SALMON */ Glib = rnd(15); pline("Eating salmon made your fingers very slippery."); } } else { pline("It contains spinach - this makes you feel like Popeye!"); lesshungry(600); if (u.ustr < 118) u.ustr += rnd(((u.ustr < 17) ? 19 : 118) - u.ustr); if (u.ustr > u.ustrmax) u.ustrmax = u.ustr; flags.botl = 1; } return (0); } int Meatdone() { u.usym = '@'; prme(); return 0; } int doeat() { struct obj *otmp; struct objclass *ftmp; int tmp; /* Is there some food (probably a heavy corpse) here on the ground? */ if (!Levitation) for (otmp = fobj; otmp; otmp = otmp->nobj) { if (otmp->ox == u.ux && otmp->oy == u.uy && otmp->olet == FOOD_SYM) { pline("There %s %s here; eat %s? [ny] ", (otmp->quan == 1) ? "is" : "are", doname(otmp), (otmp->quan == 1) ? "it" : "one"); if (readchar() == 'y') { if (otmp->quan != 1) (void) splitobj(otmp, 1); freeobj(otmp); otmp = addinv(otmp); addtobill(otmp); goto gotit; } } } otmp = getobj("%", "eat"); if (!otmp) return (0); gotit: if (otmp->otyp == TIN) { if (uwep) { switch (uwep->otyp) { case CAN_OPENER: tmp = 1; break; case DAGGER: case CRYSKNIFE: tmp = 3; break; case PICK_AXE: case AXE: tmp = 6; break; default: goto no_opener; } pline("Using your %s you try to open the tin.", aobjnam(uwep, (char *) 0)); } else { no_opener: pline("It is not so easy to open this tin."); if (Glib) { pline("The tin slips out of your hands."); if (otmp->quan > 1) { struct obj *obj; obj = splitobj(otmp, 1); if (otmp == uwep) setuwep(obj); } dropx(otmp); return (1); } tmp = 10 + rn2(1 + 500 / ((int) (u.ulevel + u.ustr))); } tin.reqtime = tmp; tin.usedtime = 0; tin.tin = otmp; occupation = opentin; occtxt = "opening the tin"; return (1); } ftmp = &objects[otmp->otyp]; multi = -ftmp->oc_delay; if (otmp->otyp >= CORPSE && eatcorpse(otmp)) goto eatx; if (!rn2(7) && otmp->otyp != FORTUNE_COOKIE) { pline("Blecch! Rotten food!"); if (!rn2(4)) { pline("You feel rather light headed."); Confusion += d(2, 4); } else if (!rn2(4) && !Blind) { pline("Everything suddenly goes dark."); Blind = d(2, 10); seeoff(0); } else if (!rn2(3)) { if (Blind) pline("The world spins and you slap against the floor."); else pline("The world spins and goes dark."); nomul(-rnd(10)); nomovemsg = "You are conscious again."; } lesshungry(ftmp->nutrition / 4); } else { if (u.uhunger >= 1500) { pline("You choke over your food."); pline("You die..."); killer = ftmp->oc_name; done("choked"); } switch (otmp->otyp) { case FOOD_RATION: if (u.uhunger <= 200) pline("That food really hit the spot!"); else if (u.uhunger <= 700) pline("That satiated your stomach!"); else { pline("You're having a hard time getting all that food down."); multi -= 2; } lesshungry(ftmp->nutrition); if (multi < 0) nomovemsg = "You finished your meal."; break; case TRIPE_RATION: pline("Yak - dog food!"); more_experienced(1, 0); flags.botl = 1; if (rn2(2)) { pline("You vomit."); morehungry(20); if (Sick) { Sick = 0; /* David Neves */ pline("What a relief!"); } } else lesshungry(ftmp->nutrition); break; default: if (otmp->otyp >= CORPSE) pline("That %s tasted terrible!", ftmp->oc_name); else pline("That %s was delicious!", ftmp->oc_name); lesshungry(ftmp->nutrition); if (otmp->otyp == DEAD_LIZARD && (Confusion > 2)) Confusion = 2; else #ifdef QUEST if (otmp->otyp == CARROT && !Blind) { u.uhorizon++; setsee(); pline("Your vision improves."); } else #endif /* QUEST */ if (otmp->otyp == FORTUNE_COOKIE) { if (Blind) { pline("This cookie has a scrap of paper inside!"); pline("What a pity, that you cannot read it!"); } else outrumor(); } else if (otmp->otyp == LUMP_OF_ROYAL_JELLY) { /* This stuff seems to be VERY healthy! */ if (u.ustrmax < 118) u.ustrmax++; if (u.ustr < u.ustrmax) u.ustr++; u.uhp += rnd(20); if (u.uhp > u.uhpmax) { if (!rn2(17)) u.uhpmax++; u.uhp = u.uhpmax; } heal_legs(); } break; } } eatx: if (multi < 0 && !nomovemsg) { static char msgbuf[BUFSZ]; (void) sprintf(msgbuf, "You finished eating the %s.", ftmp->oc_name); nomovemsg = msgbuf; } useup(otmp); return (1); } /* called in hack.main.c */ void gethungry() { --u.uhunger; if (moves % 2) { if (Regeneration) u.uhunger--; if (Hunger) u.uhunger--; /* * a3: if(Hunger & LEFT_RING) u.uhunger--; if(Hunger & * RIGHT_RING) u.uhunger--; etc. */ } if (moves % 20 == 0) { /* jimt@asgb */ if (uleft) u.uhunger--; if (uright) u.uhunger--; } newuhs(TRUE); } /* called after vomiting and after performing feats of magic */ void morehungry(num) int num; { u.uhunger -= num; newuhs(TRUE); } /* called after eating something (and after drinking fruit juice) */ void lesshungry(num) int num; { u.uhunger += num; newuhs(FALSE); } int unfaint() { u.uhs = FAINTING; flags.botl = 1; return 0; } void newuhs(incr) boolean incr; { int newhs, h = u.uhunger; newhs = (h > 1000) ? SATIATED : (h > 150) ? NOT_HUNGRY : (h > 50) ? HUNGRY : (h > 0) ? WEAK : FAINTING; if (newhs == FAINTING) { if (u.uhs == FAINTED) newhs = FAINTED; if (u.uhs <= WEAK || rn2(20 - u.uhunger / 10) >= 19) { if (u.uhs != FAINTED && multi >= 0 /* %% */ ) { pline("You faint from lack of food."); nomul(-10 + (u.uhunger / 10)); nomovemsg = "You regain consciousness."; afternmv = unfaint; newhs = FAINTED; } } else if (u.uhunger < -(int) (200 + 25 * u.ulevel)) { u.uhs = STARVED; flags.botl = 1; bot(); pline("You die from starvation."); done("starved"); } } if (newhs != u.uhs) { if (newhs >= WEAK && u.uhs < WEAK) losestr(1); /* this may kill you -- see below */ else if (newhs < WEAK && u.uhs >= WEAK && u.ustr < u.ustrmax) losestr(-1); switch (newhs) { case HUNGRY: pline((!incr) ? "You only feel hungry now." : (u.uhunger < 145) ? "You feel hungry." : "You are beginning to feel hungry."); break; case WEAK: pline((!incr) ? "You feel weak now." : (u.uhunger < 45) ? "You feel weak." : "You are beginning to feel weak."); break; } u.uhs = newhs; flags.botl = 1; if (u.uhp < 1) { pline("You die from hunger and exhaustion."); killer = "exhaustion"; done("starved"); } } } #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\ ? 'a' + (otyp - DEAD_ACID_BLOB)\ : '@' + (otyp - DEAD_HUMAN)) int poisonous(otmp) struct obj *otmp; { return (strchr(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0); } /* returns 1 if some text was printed */ int eatcorpse(otmp) struct obj *otmp; { char let = CORPSE_I_TO_C(otmp->otyp); int tp = 0; if (let != 'a' && moves > otmp->age + 50 + rn2(100)) { tp++; pline("Ulch -- that meat was tainted!"); pline("You get very sick."); Sick = 10 + rn2(10); u.usick_cause = objects[otmp->otyp].oc_name; } else if (strchr(POISONOUS, let) && rn2(5)) { tp++; pline("Ecch -- that must have been poisonous!"); if (!Poison_resistance) { losestr(rnd(4)); losehp(rnd(15), "poisonous corpse"); } else pline("You don't seem affected by the poison."); } else if (strchr("ELNOPQRUuxz", let) && rn2(5)) { tp++; pline("You feel sick."); losehp(rnd(8), "cadaver"); } switch (let) { case 'L': case 'N': case 't': Teleportation |= INTRINSIC; break; case 'W': pluslvl(); break; case 'n': u.uhp = u.uhpmax; flags.botl = 1; /* fall into next case */ case '@': pline("You cannibal! You will be sorry for this!"); /* not tp++; */ /* fall into next case */ case 'd': Aggravate_monster |= INTRINSIC; break; case 'I': if (!Invis) { Invis = 50 + rn2(100); if (!See_invisible) newsym(u.ux, u.uy); } else { Invis |= INTRINSIC; See_invisible |= INTRINSIC; } /* fall into next case */ case 'y': #ifdef QUEST u.uhorizon++; #endif /* QUEST */ /* fall into next case */ case 'B': Confusion = 50; break; case 'D': Fire_resistance |= INTRINSIC; break; case 'E': Telepat |= INTRINSIC; break; case 'F': case 'Y': Cold_resistance |= INTRINSIC; break; case 'k': case 's': Poison_resistance |= INTRINSIC; break; case 'c': pline("You turn to stone."); killer = "dead cockatrice"; done("died"); /* NOTREACHED */ case 'a': if (Stoned) { pline("What a pity - you just destroyed a future piece of art!"); tp++; Stoned = 0; } break; case 'M': pline("You cannot resist the temptation to mimic a treasure chest."); tp++; nomul(-30); afternmv = Meatdone; nomovemsg = "You now again prefer mimicking a human."; u.usym = '$'; prme(); break; } return (tp); } bsd-games-2.17/hack/hack.dog.c0000664000175000017500000003371607767741711014562 0ustar jsm28jsm28/* $NetBSD: hack.dog.c,v 1.6 2003/04/02 18:36:36 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.dog.c,v 1.6 2003/04/02 18:36:36 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #include "hack.mfndpos.h" #include "def.edog.h" #include "def.mkroom.h" const struct permonst li_dog = {"little dog", 'd', 2, 18, 6, 1, 6, sizeof(struct edog)}; const struct permonst dog = {"dog", 'd', 4, 16, 5, 1, 6, sizeof(struct edog)}; const struct permonst la_dog = {"large dog", 'd', 6, 15, 4, 2, 4, sizeof(struct edog)}; void makedog() { struct monst *mtmp = makemon(&li_dog, u.ux, u.uy); if (!mtmp) return; /* dogs were genocided */ initedog(mtmp); } void initedog(mtmp) struct monst *mtmp; { mtmp->mtame = mtmp->mpeaceful = 1; EDOG(mtmp)->hungrytime = 1000 + moves; EDOG(mtmp)->eattime = 0; EDOG(mtmp)->droptime = 0; EDOG(mtmp)->dropdist = 10000; EDOG(mtmp)->apport = 10; EDOG(mtmp)->whistletime = 0; } /* attach the monsters that went down (or up) together with @ */ struct monst *mydogs = 0; struct monst *fallen_down = 0;/* monsters that fell through a trapdoor */ /* they will appear on the next level @ goes to, even if he goes up! */ void losedogs() { struct monst *mtmp; while ((mtmp = mydogs) != NULL) { mydogs = mtmp->nmon; mtmp->nmon = fmon; fmon = mtmp; mnexto(mtmp); } while ((mtmp = fallen_down) != NULL) { fallen_down = mtmp->nmon; mtmp->nmon = fmon; fmon = mtmp; rloc(mtmp); } } void keepdogs() { struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (dist(mtmp->mx, mtmp->my) < 3 && follower(mtmp) && !mtmp->msleep && !mtmp->mfroz) { relmon(mtmp); mtmp->nmon = mydogs; mydogs = mtmp; unpmon(mtmp); keepdogs(); /* we destroyed the link, so use * recursion */ return; /* (admittedly somewhat primitive) */ } } void fall_down(mtmp) struct monst *mtmp; { relmon(mtmp); mtmp->nmon = fallen_down; fallen_down = mtmp; unpmon(mtmp); mtmp->mtame = 0; } /* return quality of food; the lower the better */ #define DOGFOOD 0 #define CADAVER 1 #define ACCFOOD 2 #define MANFOOD 3 #define APPORT 4 #define POISON 5 #define UNDEF 6 int dogfood(obj) struct obj *obj; { switch (obj->olet) { case FOOD_SYM: return ( (obj->otyp == TRIPE_RATION) ? DOGFOOD : (obj->otyp < CARROT) ? ACCFOOD : (obj->otyp < CORPSE) ? MANFOOD : (poisonous(obj) || obj->age + 50 <= moves || obj->otyp == DEAD_COCKATRICE) ? POISON : CADAVER ); default: if (!obj->cursed) return (APPORT); /* fall into next case */ case BALL_SYM: case CHAIN_SYM: case ROCK_SYM: return (UNDEF); } } /* return 0 (no move), 1 (move) or 2 (dead) */ int dog_move(struct monst *mtmp, int after) { int nx, ny, omx, omy, appr, nearer, j; int udist, chi = 0, i, whappr; struct monst *mtmp2; const struct permonst *mdat = mtmp->data; struct edog *edog = EDOG(mtmp); struct obj *obj; struct trap *trap; xchar cnt, chcnt, nix, niy; schar dogroom, uroom; xchar gx = 0, gy = 0, gtyp, otyp; /* current goal */ coord poss[9]; int info[9]; #define GDIST(x,y) ((x-gx)*(x-gx) + (y-gy)*(y-gy)) #define DDIST(x,y) ((x-omx)*(x-omx) + (y-omy)*(y-omy)) if (moves <= edog->eattime) return (0); /* dog is still eating */ omx = mtmp->mx; omy = mtmp->my; whappr = (moves - EDOG(mtmp)->whistletime < 5); if (moves > edog->hungrytime + 500 && !mtmp->mconf) { mtmp->mconf = 1; mtmp->mhpmax /= 3; if (mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; if (cansee(omx, omy)) pline("%s is confused from hunger.", Monnam(mtmp)); else pline("You feel worried about %s.", monnam(mtmp)); } else if (moves > edog->hungrytime + 750 || mtmp->mhp < 1) { if (cansee(omx, omy)) pline("%s dies from hunger.", Monnam(mtmp)); else pline("You have a sad feeling for a moment, then it passes."); mondied(mtmp); return (2); } dogroom = inroom(omx, omy); uroom = inroom(u.ux, u.uy); udist = dist(omx, omy); /* maybe we tamed him while being swallowed --jgm */ if (!udist) return (0); /* if we are carrying sth then we drop it (perhaps near @) */ /* Note: if apport == 1 then our behaviour is independent of udist */ if (mtmp->minvent) { if (!rn2(udist) || !rn2((int) edog->apport)) if ((unsigned)rn2(10) < edog->apport) { relobj(mtmp, (int) mtmp->minvis); if (edog->apport > 1) edog->apport--; edog->dropdist = udist; /* hpscdi!jon */ edog->droptime = moves; } } else { if ((obj = o_at(omx, omy)) != NULL) if (!strchr("0_", obj->olet)) { if ((otyp = dogfood(obj)) <= CADAVER) { nix = omx; niy = omy; goto eatobj; } if (obj->owt < 10 * mtmp->data->mlevel) if ((unsigned)rn2(20) < edog->apport + 3) if (rn2(udist) || !rn2((int) edog->apport)) { freeobj(obj); unpobj(obj); /* * if(levl[omx][omy].s * crsym == * obj->olet) * newsym(omx,omy); */ mpickobj(mtmp, obj); } } } /* first we look for food */ gtyp = UNDEF; /* no goal as yet */ #ifdef LINT gx = gy = 0; /* suppress 'used before set' message */ #endif /* LINT */ for (obj = fobj; obj; obj = obj->nobj) { otyp = dogfood(obj); if (otyp > gtyp || otyp == UNDEF) continue; if (inroom(obj->ox, obj->oy) != dogroom) continue; if (otyp < MANFOOD && (dogroom >= 0 || DDIST(obj->ox, obj->oy) < 10)) { if (otyp < gtyp || (otyp == gtyp && DDIST(obj->ox, obj->oy) < DDIST(gx, gy))) { gx = obj->ox; gy = obj->oy; gtyp = otyp; } } else if (gtyp == UNDEF && dogroom >= 0 && uroom == dogroom && !mtmp->minvent && edog->apport > (unsigned)rn2(8)) { gx = obj->ox; gy = obj->oy; gtyp = APPORT; } } if (gtyp == UNDEF || (gtyp != DOGFOOD && gtyp != APPORT && moves < edog->hungrytime)) { if (dogroom < 0 || dogroom == uroom) { gx = u.ux; gy = u.uy; #ifndef QUEST } else { int tmp = rooms[dogroom].fdoor; cnt = rooms[dogroom].doorct; gx = gy = FAR; /* random, far away */ while (cnt--) { if (dist(gx, gy) > dist(doors[tmp].x, doors[tmp].y)) { gx = doors[tmp].x; gy = doors[tmp].y; } tmp++; } /* here gx == FAR e.g. when dog is in a vault */ if (gx == FAR || (gx == omx && gy == omy)) { gx = u.ux; gy = u.uy; } #endif /* QUEST */ } appr = (udist >= 9) ? 1 : (mtmp->mflee) ? -1 : 0; if (after && udist <= 4 && gx == u.ux && gy == u.uy) return (0); if (udist > 1) { if (!IS_ROOM(levl[u.ux][u.uy].typ) || !rn2(4) || whappr || (mtmp->minvent && rn2((int) edog->apport))) appr = 1; } /* if you have dog food he'll follow you more closely */ if (appr == 0) { obj = invent; while (obj) { if (obj->otyp == TRIPE_RATION) { appr = 1; break; } obj = obj->nobj; } } } else appr = 1; /* gtyp != UNDEF */ if (mtmp->mconf) appr = 0; if (gx == u.ux && gy == u.uy && (dogroom != uroom || dogroom < 0)) { coord *cp; cp = gettrack(omx, omy); if (cp) { gx = cp->x; gy = cp->y; } } nix = omx; niy = omy; cnt = mfndpos(mtmp, poss, info, ALLOW_M | ALLOW_TRAPS); chcnt = 0; chi = -1; for (i = 0; i < cnt; i++) { nx = poss[i].x; ny = poss[i].y; if (info[i] & ALLOW_M) { mtmp2 = m_at(nx, ny); if (mtmp2->data->mlevel >= mdat->mlevel + 2 || mtmp2->data->mlet == 'c') continue; if (after) return (0); /* hit only once each move */ if (hitmm(mtmp, mtmp2) == 1 && rn2(4) && mtmp2->mlstmv != moves && hitmm(mtmp2, mtmp) == 2) return (2); return (0); } /* dog avoids traps */ /* but perhaps we have to pass a trap in order to follow @ */ if ((info[i] & ALLOW_TRAPS) && (trap = t_at(nx, ny))) { if (!trap->tseen && rn2(40)) continue; if (rn2(10)) continue; } /* dog eschewes cursed objects */ /* but likes dog food */ obj = fobj; while (obj) { if (obj->ox != nx || obj->oy != ny) goto nextobj; if (obj->cursed) goto nxti; if (obj->olet == FOOD_SYM && (otyp = dogfood(obj)) < MANFOOD && (otyp < ACCFOOD || edog->hungrytime <= moves)) { /* * Note: our dog likes the food so much that * he might eat it even when it conceals a * cursed object */ nix = nx; niy = ny; chi = i; eatobj: edog->eattime = moves + obj->quan * objects[obj->otyp].oc_delay; if (edog->hungrytime < moves) edog->hungrytime = moves; edog->hungrytime += 5 * obj->quan * objects[obj->otyp].nutrition; mtmp->mconf = 0; if (cansee(nix, niy)) pline("%s ate %s.", Monnam(mtmp), doname(obj)); /* perhaps this was a reward */ if (otyp != CADAVER) edog->apport += 200 / (edog->dropdist + moves - edog->droptime); delobj(obj); goto newdogpos; } nextobj: obj = obj->nobj; } for (j = 0; j < MTSZ && j < cnt - 1; j++) if (nx == mtmp->mtrack[j].x && ny == mtmp->mtrack[j].y) if (rn2(4 * (cnt - j))) goto nxti; /* * Some stupid C compilers cannot compute the whole * expression at once. */ nearer = GDIST(nx, ny); nearer -= GDIST(nix, niy); nearer *= appr; if ((nearer == 0 && !rn2(++chcnt)) || nearer < 0 || (nearer > 0 && !whappr && ((omx == nix && omy == niy && !rn2(3)) || !rn2(12)) )) { nix = nx; niy = ny; if (nearer < 0) chcnt = 0; chi = i; } nxti: ; } newdogpos: if (nix != omx || niy != omy) { if (info[chi] & ALLOW_U) { (void) hitu(mtmp, d(mdat->damn, mdat->damd) + 1); return (0); } mtmp->mx = nix; mtmp->my = niy; for (j = MTSZ - 1; j > 0; j--) mtmp->mtrack[j] = mtmp->mtrack[j - 1]; mtmp->mtrack[0].x = omx; mtmp->mtrack[0].y = omy; } if (mintrap(mtmp) == 2) /* he died */ return (2); pmon(mtmp); return (1); } /* return roomnumber or -1 */ int inroom(x, y) xchar x, y; { #ifndef QUEST struct mkroom *croom = &rooms[0]; while (croom->hx >= 0) { if (croom->hx >= x - 1 && croom->lx <= x + 1 && croom->hy >= y - 1 && croom->ly <= y + 1) return (croom - rooms); croom++; } #endif /* QUEST */ return (-1); /* not in room or on door */ } int tamedog(mtmp, obj) struct monst *mtmp; struct obj *obj; { struct monst *mtmp2; if (flags.moonphase == FULL_MOON && night() && rn2(6)) return (0); /* If we cannot tame him, at least he's no longer afraid. */ mtmp->mflee = 0; mtmp->mfleetim = 0; if (mtmp->mtame || mtmp->mfroz || #ifndef NOWORM mtmp->wormno || #endif /* NOWORM */ mtmp->isshk || mtmp->isgd || strchr(" &@12", mtmp->data->mlet)) return (0); /* no tame long worms? */ if (obj) { if (dogfood(obj) >= MANFOOD) return (0); if (cansee(mtmp->mx, mtmp->my)) { pline("%s devours the %s.", Monnam(mtmp), objects[obj->otyp].oc_name); } obfree(obj, (struct obj *) 0); } mtmp2 = newmonst(sizeof(struct edog) + mtmp->mnamelth); *mtmp2 = *mtmp; mtmp2->mxlth = sizeof(struct edog); if (mtmp->mnamelth) (void) strcpy(NAME(mtmp2), NAME(mtmp)); initedog(mtmp2); replmon(mtmp, mtmp2); return (1); } bsd-games-2.17/hack/hack.mfndpos.h0000664000175000017500000000670507767741711015462 0ustar jsm28jsm28/* $NetBSD: hack.mfndpos.h,v 1.5 2003/04/02 18:36:37 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _HACK_MFNDPOS_H_ #define _HACK_MFNDPOS_H_ #define ALLOW_TRAPS 0777 #define ALLOW_U 01000 #define ALLOW_M 02000 #define ALLOW_TM 04000 #define ALLOW_ALL (ALLOW_U | ALLOW_M | ALLOW_TM | ALLOW_TRAPS) #define ALLOW_SSM 010000 #define ALLOW_ROCK 020000 #define NOTONL 040000 #define NOGARLIC 0100000 #endif /* _HACK_MFNDPOS_H_ */ bsd-games-2.17/hack/hack.tty.c0000664000175000017500000002427207767741711014626 0ustar jsm28jsm28/* $NetBSD: hack.tty.c,v 1.12 2003/08/07 09:37:19 agc Exp $ */ /*- * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint #if 0 static char sccsid[] = "@(#)hack.tty.c 8.1 (Berkeley) 5/31/93"; #else __RCSID("$NetBSD: hack.tty.c,v 1.12 2003/08/07 09:37:19 agc Exp $"); #endif #endif /* not lint */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* hack.tty.c - version 1.0.3 */ /* * With thanks to the people who sent code for SYSV - hpscdi!jon, * arnold@ucsf-cgl, wcs@bo95b, cbcephus!pds and others. */ #include #include #include "hack.h" #include "extern.h" /* * Some systems may have getchar() return EOF for various reasons, and * we should not quit before seeing at least NR_OF_EOFS consecutive EOFs. */ #ifndef BSD #define NR_OF_EOFS 20 #endif /* BSD */ static char erase_char, kill_char; static boolean settty_needed = FALSE; struct termios inittyb, curttyb; /* * Get initial state of terminal, set ospeed (for termcap routines) * and switch off tab expansion if necessary. * Called by startup() in termcap.c and after returning from ! or ^Z */ void gettty() { if (tcgetattr(0, &inittyb) < 0) perror("Hack (gettty)"); curttyb = inittyb; ospeed = cfgetospeed(&inittyb); erase_char = inittyb.c_cc[VERASE]; kill_char = inittyb.c_cc[VKILL]; getioctls(); /* do not expand tabs - they might be needed inside a cm sequence */ if (curttyb.c_oflag & OXTABS) { curttyb.c_oflag &= ~OXTABS; setctty(); } settty_needed = TRUE; } /* reset terminal to original state */ void settty(s) const char *s; { clear_screen(); end_screen(); if (s) printf("%s", s); (void) fflush(stdout); if (tcsetattr(0, TCSADRAIN, &inittyb) < 0) perror("Hack (settty)"); flags.echo = (inittyb.c_lflag & ECHO) ? ON : OFF; flags.cbreak = (inittyb.c_lflag & ICANON) ? OFF : ON; setioctls(); } void setctty() { if (tcsetattr(0, TCSADRAIN, &curttyb) < 0) perror("Hack (setctty)"); } void setftty() { int change = 0; flags.cbreak = ON; flags.echo = OFF; /* Should use (ECHO|CRMOD) here instead of ECHO */ if (curttyb.c_lflag & ECHO) { curttyb.c_lflag &= ~ECHO; change++; } if (curttyb.c_lflag & ICANON) { curttyb.c_lflag &= ~ICANON; /* be satisfied with one character; no timeout */ curttyb.c_cc[VMIN] = 1; curttyb.c_cc[VTIME] = 0; change++; } if (change) { setctty(); } start_screen(); } /* fatal error */ /* VARARGS1 */ void error(const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (settty_needed) settty((char *) 0); vprintf(fmt, ap); va_end(ap); putchar('\n'); exit(1); } /* * Read a line closed with '\n' into the array char bufp[BUFSZ]. * (The '\n' is not stored. The string is closed with a '\0'.) * Reading can be interrupted by an escape ('\033') - now the * resulting string is "\033". */ void getlin(bufp) char *bufp; { char *obufp = bufp; int c; flags.toplin = 2; /* nonempty, no --More-- required */ for (;;) { (void) fflush(stdout); if ((c = getchar()) == EOF) { *bufp = 0; return; } if (c == '\033') { *obufp = c; obufp[1] = 0; return; } if (c == erase_char || c == '\b') { if (bufp != obufp) { bufp--; putstr("\b \b"); /* putsym converts \b */ } else bell(); } else if (c == '\n') { *bufp = 0; return; } else if (' ' <= c && c < '\177') { /* * avoid isprint() - some people don't have it ' ' is * not always a printing char */ *bufp = c; bufp[1] = 0; putstr(bufp); if (bufp - obufp < BUFSZ - 1 && bufp - obufp < COLNO) bufp++; } else if (c == kill_char || c == '\177') { /* Robert Viduya */ /* this test last - @ might be the kill_char */ while (bufp != obufp) { bufp--; putstr("\b \b"); } } else bell(); } } void getret() { cgetret(""); } void cgetret(s) const char *s; { putsym('\n'); if (flags.standout) standoutbeg(); putstr("Hit "); putstr(flags.cbreak ? "space" : "return"); putstr(" to continue: "); if (flags.standout) standoutend(); xwaitforspace(s); } char morc; /* tell the outside world what char he used */ void xwaitforspace(s) const char *s; /* chars allowed besides space or return */ { int c; morc = 0; while ((c = readchar()) != '\n') { if (flags.cbreak) { if (c == ' ') break; if (s && strchr(s, c)) { morc = c; break; } bell(); } } } char * parse() { static char inputline[COLNO]; int foo; flags.move = 1; if (!Invisible) curs_on_u(); else home(); while ((foo = readchar()) >= '0' && foo <= '9') multi = 10 * multi + foo - '0'; if (multi) { multi--; save_cm = inputline; } inputline[0] = foo; inputline[1] = 0; if (foo == 'f' || foo == 'F') { inputline[1] = getchar(); #ifdef QUEST if (inputline[1] == foo) inputline[2] = getchar(); else #endif /* QUEST */ inputline[2] = 0; } if (foo == 'm' || foo == 'M') { inputline[1] = getchar(); inputline[2] = 0; } clrlin(); return (inputline); } char readchar() { int sym; (void) fflush(stdout); if ((sym = getchar()) == EOF) #ifdef NR_OF_EOFS { /* * Some SYSV systems seem to return EOFs for various reasons * (?like when one hits break or for interrupted systemcalls?), * and we must see several before we quit. */ int cnt = NR_OF_EOFS; while (cnt--) { clearerr(stdin); /* omit if clearerr is * undefined */ if ((sym = getchar()) != EOF) goto noteof; } end_of_input(); noteof: ; } #else end_of_input(); #endif /* NR_OF_EOFS */ if (flags.toplin == 1) flags.toplin = 2; return ((char) sym); } void end_of_input() { settty("End of input?\n"); clearlocks(); exit(0); } bsd-games-2.17/hack/help0000664000175000017500000001202007641024615013560 0ustar jsm28jsm28 Welcome to HACK! ( description of version 1.0.3 ) Hack is a Dungeons and Dragons like game where you (the adventurer) descend into the depths of the dungeon in search of the Amulet of Yendor (reputed to be hidden on the twentieth level). You are accompanied by a little dog that can help you in many ways and can be trained to do all sorts of things. On the way you will find useful (or useless) items, (quite possibly with magic properties) and assorted monsters. You attack a monster by trying to move into the space a monster is in (but often it is much wiser to leave it alone). Unlike most adventure games, which give you a verbal description of your location, hack gives you a visual image of the dungeon level you are on. Hack uses the following symbols: A to Z and a to z: monsters. You can find out what a letter represents by saying "/ (letter)", as in "/A", which will tell you that 'A' is a giant ant. - and | These form the walls of a room (or maze). . this is the floor of a room. # this is a corridor. > this is the staircase to the next level. < the staircase to the previous level. ` A large boulder. @ You (usually). ^ A trap. ) A weapon of some sort. ( Some other useful object (key, rope, dynamite, camera, ...) [ A suit of armor. % A piece of food (not necessarily healthy ...). / A wand. = A ring. ? A scroll. ! A magic potion. $ A pile or pot of gold. Commands: Hack knows the following commands: ? help: print this list. Q Quit the game. S Save the game. ! Escape to a shell. ^Z Suspend the game. < up: go up the staircase (if you are standing on it). > down: go down (just like up). kjhlyubn - go one step in the direction indicated. k: north (i.e., to the top of the screen), j: south, h: west, l: east, y: nw, u: ne, b: sw, n: se. KJHLYUBN - Go in that direction until you hit a wall or run into something. m (followed by one of kjhlyubn): move without picking up any objects. M (followed by one of KJHLYUBN): Move far, no pickup. f (followed by one of kjhlyubn): move until something interesting is found. F (followed by one of KJHLYUBN): as previous, but forking of corridors is not considered interesting. i print your inventory. I print selected parts of your inventory, like in I* - print all gems in inventory; IU - print all unpaid items; IX - print all used up items that are on your shopping bill; I$ - count your money. s search for secret doors and traps around you. ^ ask for the type of a trap you found earlier. ) ask for current wielded weapon. [ ask for current armor. = ask for current rings. $ count how many gold pieces you are carrying. . rest, do nothing. , pick up some things. : look at what is here. ^T teleport. ^R redraw the screen. ^P repeat last message (subsequent ^P's repeat earlier messages). / (followed by any symbol): tell what this symbol represents. \ tell what has been discovered. e eat food. w wield weapon. w- means: wield nothing, use bare hands. q drink (quaff) a potion. r read a scroll. T Takeoff armor. R Remove Ring. W Wear armor. P Put on a ring. z zap a wand. t throw an object or shoot an arrow. p pay your shopping bill. d drop something. d7a: drop seven items of object a. D Drop several things. In answer to the question "What kinds of things do you want to drop? [!%= au]" you should give zero or more object symbols possibly followed by 'a' and/or 'u'. 'a' means: drop all such objects, without asking for confirmation. 'u' means: drop only unpaid objects (when in a shop). a use, apply - Generic command for using a key to lock or unlock a door, using a camera, using a rope, etc. c call: name a certain object or class of objects. C Call: Name an individual monster. E Engrave: Write a message in the dust on the floor. E- means: use fingers for writing. O Set options. You will be asked to enter an option line. If this is empty, the current options are reported. Otherwise it should be a list of options separated by commas. Possible boolean options are: oneline, time, news, tombstone, rest_on_space, fixinvlet, beginner, male, female. They can be negated by prefixing them with '!' or "no". A string option is name; it supplies the answer to the question "Who are you?"; it may have a suffix. A compound option is endgame; it is followed by a description of what parts of the list of topscorers should be printed when the game is finished. Usually one will not want to use the 'O' command, but instead put a HACKOPTIONS="...." line in one's environment. v print version number. You can put a number before a command to repeat it that many times, as in "20s" or "40.". At present, some information is displayed on the bottom line. (It is expected that this information will go away in future versions.) You see on what dungeon level you are, how many hit points you have now (and will have when fully recovered), what your armor class is (the lower the better), your strength, experience level and the state of your stomach. Have Fun, and Good Hacking! bsd-games-2.17/hack/Makefrag0000664000175000017500000000601207077410364014354 0ustar jsm28jsm28# Makefrag - makefile fragment for hack # # Copyright (c) 2000 Joseph Samuel Myers. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. hack_DIRS := $(GAMESDIR) $(MAN6DIR) hack_CLEANFILES := hack.onames.h hack_all: hack/hack hack/hack.6 hack/hack.onames.h: hack/def.objects.h hack/makedefs hack/makedefs $< >$@ hack/alloc.d hack/hack.Decl.d hack/hack.apply.d hack/hack.bones.d \ hack/hack.d hack/hack.cmd.d hack/hack.do.d hack/hack.do_name.d \ hack/hack.do_wear.d hack/hack.dog.d hack/hack.eat.d hack/hack.end.d \ hack/hack.engrave.d hack/hack.fight.d hack/hack.invent.d \ hack/hack.ioctl.d hack/hack.lev.d hack/hack.main.d hack/hack.makemon.d \ hack/hack.mhitu.d hack/hack.mklev.d hack/hack.mkmaze.d \ hack/hack.mkobj.d hack/hack.mkshop.d hack/hack.mon.d hack/hack.monst.d \ hack/hack.o_init.d hack/hack.objnam.d hack/hack.options.d \ hack/hack.pager.d hack/hack.potion.d hack/hack.pri.d hack/hack.read.d \ hack/hack.rip.d hack/hack.rumors.d hack/hack.save.d hack/hack.search.d \ hack/hack.shk.d hack/hack.shknam.d hack/hack.steal.d \ hack/hack.termcap.d hack/hack.timeout.d hack/hack.topl.d \ hack/hack.track.d hack/hack.trap.d hack/hack.tty.d hack/hack.u_init.d \ hack/hack.unix.d hack/hack.vault.d hack/hack.version.d \ hack/hack.wield.d hack/hack.wizard.d hack/hack.worm.d hack/hack.worn.d \ hack/hack.zap.d hack/rnd.d: hack/hack.onames.h hack_install: hack_all $(INSTALL_SCORE_GAME) hack/hack $(INSTALL_PREFIX)$(GAMESDIR)/hack $(HIDE_GAME) hack $(INSTALL_HACK_DIR) $(INSTALL_PREFIX)$(HACK_DIR) set -e; for f in data help hh rumors; do $(INSTALL_DATA) hack/$$f $(INSTALL_PREFIX)$(HACK_DIR)/$$f; done $(INSTALL_SCORE_FILE) $(HACK_DIR)/perm $(INSTALL_SCORE_FILE) $(HACK_DIR)/record $(INSTALL_MANUAL) hack/hack.6 bsd-games-2.17/hack/hack.mkmaze.c0000664000175000017500000001425007767741711015265 0ustar jsm28jsm28/* $NetBSD: hack.mkmaze.c,v 1.6 2003/04/02 18:36:38 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.mkmaze.c,v 1.6 2003/04/02 18:36:38 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" #include "def.mkroom.h" /* not really used */ const struct permonst hell_hound = {"hell hound", 'd', 12, 14, 2, 3, 6, 0}; void makemaz() { int x, y; int zx, zy; coord mm; boolean al = (dlevel >= 30 && !flags.made_amulet); for (x = 2; x < COLNO - 1; x++) for (y = 2; y < ROWNO - 1; y++) levl[x][y].typ = (x % 2 && y % 2) ? 0 : HWALL; if (al) { struct monst *mtmp; zx = 2 * (COLNO / 4) - 1; zy = 2 * (ROWNO / 4) - 1; for (x = zx - 2; x < zx + 4; x++) for (y = zy - 2; y <= zy + 2; y++) { levl[x][y].typ = (y == zy - 2 || y == zy + 2 || x == zx - 2 || x == zx + 3) ? POOL : (y == zy - 1 || y == zy + 1 || x == zx - 1 || x == zx + 2) ? HWALL : ROOM; } (void) mkobj_at(AMULET_SYM, zx, zy); flags.made_amulet = 1; walkfrom(zx + 4, zy); if ((mtmp = makemon(&hell_hound, zx, zy)) != NULL) mtmp->msleep = 1; if ((mtmp = makemon(PM_WIZARD, zx + 1, zy)) != NULL) { mtmp->msleep = 1; flags.no_of_wizards = 1; } } else { mm = mazexy(); zx = mm.x; zy = mm.y; walkfrom(zx, zy); (void) mksobj_at(WAN_WISHING, zx, zy); (void) mkobj_at(ROCK_SYM, zx, zy); /* put a rock on top of * it */ } for (x = 2; x < COLNO - 1; x++) for (y = 2; y < ROWNO - 1; y++) { switch (levl[x][y].typ) { case HWALL: levl[x][y].scrsym = '-'; break; case ROOM: levl[x][y].scrsym = '.'; break; } } for (x = rn1(8, 11); x; x--) { mm = mazexy(); (void) mkobj_at(rn2(2) ? GEM_SYM : 0, mm.x, mm.y); } for (x = rn1(10, 2); x; x--) { mm = mazexy(); (void) mkobj_at(ROCK_SYM, mm.x, mm.y); } mm = mazexy(); (void) makemon(PM_MINOTAUR, mm.x, mm.y); for (x = rn1(5, 7); x; x--) { mm = mazexy(); (void) makemon((struct permonst *) 0, mm.x, mm.y); } for (x = rn1(6, 7); x; x--) { mm = mazexy(); mkgold(0L, mm.x, mm.y); } for (x = rn1(6, 7); x; x--) mktrap(0, 1, (struct mkroom *) 0); mm = mazexy(); levl[(xupstair = mm.x)][(yupstair = mm.y)].scrsym = '<'; levl[xupstair][yupstair].typ = STAIRS; xdnstair = ydnstair = 0; } void walkfrom(x, y) int x, y; { int q, a, dir; int dirs[4]; levl[x][y].typ = ROOM; while (1) { q = 0; for (a = 0; a < 4; a++) if (okay(x, y, a)) dirs[q++] = a; if (!q) return; dir = dirs[rn2(q)]; move(&x, &y, dir); levl[x][y].typ = ROOM; move(&x, &y, dir); walkfrom(x, y); } } void move(x, y, dir) int *x, *y; int dir; { switch (dir) { case 0: --(*y); break; case 1: (*x)++; break; case 2: (*y)++; break; case 3: --(*x); break; } } int okay(x, y, dir) int x, y; int dir; { move(&x, &y, dir); move(&x, &y, dir); if (x < 3 || y < 3 || x > COLNO - 3 || y > ROWNO - 3 || levl[x][y].typ != 0) return (0); else return (1); } coord mazexy() { coord mm; mm.x = 3 + 2 * rn2(COLNO / 2 - 2); mm.y = 3 + 2 * rn2(ROWNO / 2 - 2); return mm; } bsd-games-2.17/hack/hack.lev.c0000664000175000017500000002242707767741711014574 0ustar jsm28jsm28/* $NetBSD: hack.lev.c,v 1.6 2003/04/02 18:36:37 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.lev.c,v 1.6 2003/04/02 18:36:37 jsm Exp $"); #endif /* not lint */ #include #include #include "hack.h" #include "extern.h" #include "def.mkroom.h" #ifndef NOWORM #include "def.wseg.h" #endif /* NOWORM */ boolean level_exists[MAXLEVEL + 1]; void savelev(fd, lev) int fd; xchar lev; { #ifndef NOWORM struct wseg *wtmp, *wtmp2; int tmp; #endif /* NOWORM */ if (fd < 0) panic("Save on bad file!"); /* impossible */ if (lev >= 0 && lev <= MAXLEVEL) level_exists[lev] = TRUE; bwrite(fd, (char *) &hackpid, sizeof(hackpid)); bwrite(fd, (char *) &lev, sizeof(lev)); bwrite(fd, (char *) levl, sizeof(levl)); bwrite(fd, (char *) &moves, sizeof(long)); bwrite(fd, (char *) &xupstair, sizeof(xupstair)); bwrite(fd, (char *) &yupstair, sizeof(yupstair)); bwrite(fd, (char *) &xdnstair, sizeof(xdnstair)); bwrite(fd, (char *) &ydnstair, sizeof(ydnstair)); savemonchn(fd, fmon); savegoldchn(fd, fgold); savetrapchn(fd, ftrap); saveobjchn(fd, fobj); saveobjchn(fd, billobjs); billobjs = 0; save_engravings(fd); #ifndef QUEST bwrite(fd, (char *) rooms, sizeof(rooms)); bwrite(fd, (char *) doors, sizeof(doors)); #endif /* QUEST */ fgold = 0; ftrap = 0; fmon = 0; fobj = 0; #ifndef NOWORM bwrite(fd, (char *) wsegs, sizeof(wsegs)); for (tmp = 1; tmp < 32; tmp++) { for (wtmp = wsegs[tmp]; wtmp; wtmp = wtmp2) { wtmp2 = wtmp->nseg; bwrite(fd, (char *) wtmp, sizeof(struct wseg)); } wsegs[tmp] = 0; } bwrite(fd, (char *) wgrowtime, sizeof(wgrowtime)); #endif /* NOWORM */ } void bwrite(fd, loc, num) int fd; const void *loc; unsigned num; { if (write(fd, loc, num) != (ssize_t)num) panic("cannot write %u bytes to file #%d", num, fd); } void saveobjchn(fd, otmp) int fd; struct obj *otmp; { struct obj *otmp2; unsigned xl; int minusone = -1; while (otmp) { otmp2 = otmp->nobj; xl = otmp->onamelth; bwrite(fd, (char *) &xl, sizeof(int)); bwrite(fd, (char *) otmp, xl + sizeof(struct obj)); free((char *) otmp); otmp = otmp2; } bwrite(fd, (char *) &minusone, sizeof(int)); } void savemonchn(fd, mtmp) int fd; struct monst *mtmp; { struct monst *mtmp2; unsigned xl; int minusone = -1; const struct permonst *monbegin = &mons[0]; bwrite(fd, &monbegin, sizeof(monbegin)); while (mtmp) { mtmp2 = mtmp->nmon; xl = mtmp->mxlth + mtmp->mnamelth; bwrite(fd, (char *) &xl, sizeof(int)); bwrite(fd, (char *) mtmp, xl + sizeof(struct monst)); if (mtmp->minvent) saveobjchn(fd, mtmp->minvent); free((char *) mtmp); mtmp = mtmp2; } bwrite(fd, (char *) &minusone, sizeof(int)); } void savegoldchn(fd, gold) int fd; struct gold *gold; { struct gold *gold2; while (gold) { gold2 = gold->ngold; bwrite(fd, (char *) gold, sizeof(struct gold)); free((char *) gold); gold = gold2; } bwrite(fd, nul, sizeof(struct gold)); } void savetrapchn(fd, trap) int fd; struct trap *trap; { struct trap *trap2; while (trap) { trap2 = trap->ntrap; bwrite(fd, (char *) trap, sizeof(struct trap)); free((char *) trap); trap = trap2; } bwrite(fd, nul, sizeof(struct trap)); } void getlev(fd, pid, lev) int fd, pid; xchar lev; { struct gold *gold; struct trap *trap; #ifndef NOWORM struct wseg *wtmp; #endif /* NOWORM */ int tmp; long omoves; int hpid; xchar dlvl; /* First some sanity checks */ mread(fd, (char *) &hpid, sizeof(hpid)); mread(fd, (char *) &dlvl, sizeof(dlvl)); if ((pid && pid != hpid) || (lev && dlvl != lev)) { pline("Strange, this map is not as I remember it."); pline("Somebody is trying some trickery here ..."); pline("This game is void ..."); done("tricked"); } fgold = 0; ftrap = 0; mread(fd, (char *) levl, sizeof(levl)); mread(fd, (char *) &omoves, sizeof(omoves)); mread(fd, (char *) &xupstair, sizeof(xupstair)); mread(fd, (char *) &yupstair, sizeof(yupstair)); mread(fd, (char *) &xdnstair, sizeof(xdnstair)); mread(fd, (char *) &ydnstair, sizeof(ydnstair)); fmon = restmonchn(fd); /* regenerate animals while on another level */ { long tmoves = (moves > omoves) ? moves - omoves : 0; struct monst *mtmp, *mtmp2; for (mtmp = fmon; mtmp; mtmp = mtmp2) { long newhp; /* tmoves may be very large */ mtmp2 = mtmp->nmon; if (strchr(genocided, mtmp->data->mlet)) { mondead(mtmp); continue; } if (mtmp->mtame && tmoves > 250) { mtmp->mtame = 0; mtmp->mpeaceful = 0; } newhp = mtmp->mhp + (strchr(MREGEN, mtmp->data->mlet) ? tmoves : tmoves / 20); if (newhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; else mtmp->mhp = newhp; } } setgd(); gold = newgold(); mread(fd, (char *) gold, sizeof(struct gold)); while (gold->gx) { gold->ngold = fgold; fgold = gold; gold = newgold(); mread(fd, (char *) gold, sizeof(struct gold)); } free((char *) gold); trap = newtrap(); mread(fd, (char *) trap, sizeof(struct trap)); while (trap->tx) { trap->ntrap = ftrap; ftrap = trap; trap = newtrap(); mread(fd, (char *) trap, sizeof(struct trap)); } free((char *) trap); fobj = restobjchn(fd); billobjs = restobjchn(fd); rest_engravings(fd); #ifndef QUEST mread(fd, (char *) rooms, sizeof(rooms)); mread(fd, (char *) doors, sizeof(doors)); #endif /* QUEST */ #ifndef NOWORM mread(fd, (char *) wsegs, sizeof(wsegs)); for (tmp = 1; tmp < 32; tmp++) if (wsegs[tmp]) { wheads[tmp] = wsegs[tmp] = wtmp = newseg(); while (1) { mread(fd, (char *) wtmp, sizeof(struct wseg)); if (!wtmp->nseg) break; wheads[tmp]->nseg = wtmp = newseg(); wheads[tmp] = wtmp; } } mread(fd, (char *) wgrowtime, sizeof(wgrowtime)); #endif /* NOWORM */ } void mread(fd, buf, len) int fd; char *buf; unsigned len; { int rlen; rlen = read(fd, buf, (int) len); if (rlen != (int)len) { pline("Read %d instead of %u bytes.\n", rlen, len); if (restoring) { (void) unlink(SAVEF); error("Error restoring old game."); } panic("Error reading level file."); } } void mklev() { if (getbones()) return; in_mklev = TRUE; makelevel(); in_mklev = FALSE; } bsd-games-2.17/hack/def.objects.h0000664000175000017500000003234307767741711015272 0ustar jsm28jsm28/* $NetBSD: def.objects.h,v 1.6 2003/04/02 18:36:34 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _DEF_OBJECTS_H_ #define _DEF_OBJECTS_H_ /* objects have letter " % ) ( 0 _ ` [ ! ? / = * */ #include "config.h" #include "def.objclass.h" struct objclass objects[] = { { "strange object", NULL, NULL, 1, 0, ILLOBJ_SYM, 0, 0, 0, 0, 0, 0 }, { "amulet of Yendor", NULL, NULL, 1, 0, AMULET_SYM, 100, 0, 2, 0, 0, 0 }, #define FOOD(name,prob,delay,weight,nutrition) { name, NULL, NULL, 1, 1,\ FOOD_SYM, prob, delay, weight, 0, 0, nutrition } /* dog eats foods 0-4 but prefers 1 above 0,2,3,4 */ /* food 4 can be read */ /* food 5 improves your vision */ /* food 6 makes you stronger (like Popeye) */ /* foods CORPSE up to CORPSE+52 are cadavers */ FOOD("food ration", 50, 5, 4, 800), FOOD("tripe ration", 20, 1, 2, 200), FOOD("pancake", 3, 1, 1, 200), FOOD("dead lizard", 3, 0, 1, 40), FOOD("fortune cookie", 7, 0, 1, 40), FOOD("carrot", 2, 0, 1, 50), FOOD("tin", 7, 0, 1, 0), FOOD("orange", 1, 0, 1, 80), FOOD("apple", 1, 0, 1, 50), FOOD("pear", 1, 0, 1, 50), FOOD("melon", 1, 0, 1, 100), FOOD("banana", 1, 0, 1, 80), FOOD("candy bar", 1, 0, 1, 100), FOOD("egg", 1, 0, 1, 80), FOOD("clove of garlic", 1, 0, 1, 40), FOOD("lump of royal jelly", 0, 0, 1, 200), FOOD("dead human", 0, 4, 40, 400), FOOD("dead giant ant", 0, 1, 3, 30), FOOD("dead giant bat", 0, 1, 3, 30), FOOD("dead centaur", 0, 5, 50, 500), FOOD("dead dragon", 0, 15, 150, 1500), FOOD("dead floating eye", 0, 1, 1, 10), FOOD("dead freezing sphere", 0, 1, 1, 10), FOOD("dead gnome", 0, 1, 10, 100), FOOD("dead hobgoblin", 0, 2, 20, 200), FOOD("dead stalker", 0, 4, 40, 400), FOOD("dead jackal", 0, 1, 10, 100), FOOD("dead kobold", 0, 1, 10, 100), FOOD("dead leprechaun", 0, 4, 40, 400), FOOD("dead mimic", 0, 4, 40, 400), FOOD("dead nymph", 0, 4, 40, 400), FOOD("dead orc", 0, 2, 20, 200), FOOD("dead purple worm", 0, 7, 70, 700), FOOD("dead quasit", 0, 2, 20, 200), FOOD("dead rust monster", 0, 5, 50, 500), FOOD("dead snake", 0, 1, 10, 100), FOOD("dead troll", 0, 4, 40, 400), FOOD("dead umber hulk", 0, 5, 50, 500), FOOD("dead vampire", 0, 4, 40, 400), FOOD("dead wraith", 0, 1, 1, 10), FOOD("dead xorn", 0, 7, 70, 700), FOOD("dead yeti", 0, 7, 70, 700), FOOD("dead zombie", 0, 1, 3, 30), FOOD("dead acid blob", 0, 1, 3, 30), FOOD("dead giant beetle", 0, 1, 1, 10), FOOD("dead cockatrice", 0, 1, 3, 30), FOOD("dead dog", 0, 2, 20, 200), FOOD("dead ettin", 0, 1, 3, 30), FOOD("dead fog cloud", 0, 1, 1, 10), FOOD("dead gelatinous cube", 0, 1, 10, 100), FOOD("dead homunculus", 0, 2, 20, 200), FOOD("dead imp", 0, 1, 1, 10), FOOD("dead jaguar", 0, 3, 30, 300), FOOD("dead killer bee", 0, 1, 1, 10), FOOD("dead leocrotta", 0, 5, 50, 500), FOOD("dead minotaur", 0, 7, 70, 700), FOOD("dead nurse", 0, 4, 40, 400), FOOD("dead owlbear", 0, 7, 70, 700), FOOD("dead piercer", 0, 2, 20, 200), FOOD("dead quivering blob", 0, 1, 10, 100), FOOD("dead giant rat", 0, 1, 3, 30), FOOD("dead giant scorpion", 0, 1, 10, 100), FOOD("dead tengu", 0, 3, 30, 300), FOOD("dead unicorn", 0, 3, 30, 300), FOOD("dead violet fungi", 0, 1, 10, 100), FOOD("dead long worm", 0, 5, 50, 500), /* %% wt of long worm should be proportional to its length */ FOOD("dead xan", 0, 3, 30, 300), FOOD("dead yellow light", 0, 1, 1, 10), FOOD("dead zruty", 0, 6, 60, 600), /* weapons ... - ROCK come several at a time */ /* weapons ... - (ROCK-1) are shot using idem+(BOW-ARROW) */ /* weapons AXE, SWORD, THSWORD are good for worm-cutting */ /* weapons (PICK-)AXE, DAGGER, CRYSKNIFE are good for tin-opening */ #define WEAPON(name,prob,wt,ldam,sdam) { name, NULL, NULL, 1, 0 /*%%*/,\ WEAPON_SYM, prob, 0, wt, ldam, sdam, 0 } WEAPON("arrow", 7, 0, 6, 6), WEAPON("sling bullet", 7, 0, 4, 6), WEAPON("crossbow bolt", 7, 0, 4, 6), WEAPON("dart", 7, 0, 3, 2), WEAPON("rock", 6, 1, 3, 3), WEAPON("boomerang", 2, 3, 9, 9), WEAPON("mace", 9, 3, 6, 7), WEAPON("axe", 6, 3, 6, 4), WEAPON("flail", 6, 3, 6, 5), WEAPON("long sword", 8, 3, 8, 12), WEAPON("two handed sword", 6, 4, 12, 6), WEAPON("dagger", 6, 3, 4, 3), WEAPON("worm tooth", 0, 4, 2, 2), WEAPON("crysknife", 0, 3, 10, 10), WEAPON("spear", 6, 3, 6, 8), WEAPON("bow", 6, 3, 4, 6), WEAPON("sling", 5, 3, 6, 6), WEAPON("crossbow", 6, 3, 4, 6), { "whistle", "whistle", NULL, 0, 0, TOOL_SYM, 90, 0, 2, 0, 0, 0 }, { "magic whistle", "whistle", NULL, 0, 0, TOOL_SYM, 10, 0, 2, 0, 0, 0 }, { "expensive camera", NULL, NULL, 1, 1, TOOL_SYM, 0, 0, 3, 0, 0, 0 }, { "ice box", "large box", NULL, 0, 0, TOOL_SYM, 0, 0, 40, 0, 0, 0 }, { "pick-axe", NULL, NULL, 1, 1, TOOL_SYM, 0, 0, 5, 6, 3, 0 }, { "can opener", NULL, NULL, 1, 1, TOOL_SYM, 0, 0, 1, 0, 0, 0 }, { "heavy iron ball", NULL, NULL, 1, 0, BALL_SYM, 100, 0, 20, 0, 0, 0 }, { "iron chain", NULL, NULL, 1, 0, CHAIN_SYM, 100, 0, 20, 0, 0, 0 }, { "enormous rock", NULL, NULL, 1, 0, ROCK_SYM, 100, 0, 200 /* > MAX_CARR_CAP */, 0, 0, 0 }, #define ARMOR(name,prob,delay,ac,can) { name, NULL, NULL, 1, 0,\ ARMOR_SYM, prob, delay, 8, ac, can, 0 } ARMOR("helmet", 3, 1, 9, 0), ARMOR("plate mail", 5, 5, 3, 2), ARMOR("splint mail", 8, 5, 4, 1), ARMOR("banded mail", 10, 5, 4, 0), ARMOR("chain mail", 10, 5, 5, 1), ARMOR("scale mail", 10, 5, 6, 0), ARMOR("ring mail", 15, 5, 7, 0), /* the armors below do not rust */ ARMOR("studded leather armor", 13, 3, 7, 1), ARMOR("leather armor", 17, 3, 8, 0), ARMOR("elven cloak", 5, 0, 9, 3), ARMOR("shield", 3, 0, 9, 0), ARMOR("pair of gloves", 1, 1, 9, 0), #define POTION(name,color) { name, color, NULL, 0, 1,\ POTION_SYM, 0, 0, 2, 0, 0, 0 } POTION("restore strength", "orange"), POTION("booze", "bubbly"), POTION("invisibility", "glowing"), POTION("fruit juice", "smoky"), POTION("healing", "pink"), POTION("paralysis", "puce"), POTION("monster detection", "purple"), POTION("object detection", "yellow"), POTION("sickness", "white"), POTION("confusion", "swirly"), POTION("gain strength", "purple-red"), POTION("speed", "ruby"), POTION("blindness", "dark green"), POTION("gain level", "emerald"), POTION("extra healing", "sky blue"), POTION("levitation", "brown"), POTION(NULL, "brilliant blue"), POTION(NULL, "clear"), POTION(NULL, "magenta"), POTION(NULL, "ebony"), #define SCROLL(name,text,prob) { name, text, NULL, 0, 1,\ SCROLL_SYM, prob, 0, 3, 0, 0, 0 } SCROLL("mail", "KIRJE", 0), SCROLL("enchant armor", "ZELGO MER", 6), SCROLL("destroy armor", "JUYED AWK YACC", 5), SCROLL("confuse monster", "NR 9", 5), SCROLL("scare monster", "XIXAXA XOXAXA XUXAXA", 4), SCROLL("blank paper", "READ ME", 3), SCROLL("remove curse", "PRATYAVAYAH", 6), SCROLL("enchant weapon", "DAIYEN FOOELS", 6), SCROLL("damage weapon", "HACKEM MUCHE", 5), SCROLL("create monster", "LEP GEX VEN ZEA", 5), SCROLL("taming", "PRIRUTSENIE", 1), SCROLL("genocide", "ELBIB YLOH",2), SCROLL("light", "VERR YED HORRE", 10), SCROLL("teleportation", "VENZAR BORGAVVE", 5), SCROLL("gold detection", "THARR", 4), SCROLL("food detection", "YUM YUM", 1), SCROLL("identify", "KERNOD WEL", 18), SCROLL("magic mapping", "ELAM EBOW", 5), SCROLL("amnesia", "DUAM XNAHT", 3), SCROLL("fire", "ANDOVA BEGARIN", 5), SCROLL("punishment", "VE FORBRYDERNE", 1), SCROLL(NULL, "VELOX NEB", 0), SCROLL(NULL, "FOOBIE BLETCH", 0), SCROLL(NULL, "TEMOV", 0), SCROLL(NULL, "GARVEN DEH", 0), #define WAND(name,metal,prob,flags) { name, metal, NULL, 0, 0,\ WAND_SYM, prob, 0, 3, flags, 0, 0 } WAND("light", "iridium", 10, NODIR), WAND("secret door detection", "tin", 5, NODIR), WAND("create monster", "platinum", 5, NODIR), WAND("wishing", "glass", 1, NODIR), WAND("striking", "zinc", 9, IMMEDIATE), WAND("slow monster", "balsa", 5, IMMEDIATE), WAND("speed monster", "copper", 5, IMMEDIATE), WAND("undead turning", "silver", 5, IMMEDIATE), WAND("polymorph", "brass", 5, IMMEDIATE), WAND("cancellation", "maple", 5, IMMEDIATE), WAND("teleportation", "pine", 5, IMMEDIATE), WAND("make invisible", "marble", 9, IMMEDIATE), WAND("digging", "iron", 5, RAY), WAND("magic missile", "aluminium", 10, RAY), WAND("fire", "steel", 5, RAY), WAND("sleep", "curved", 5, RAY), WAND("cold", "short", 5, RAY), WAND("death", "long", 1, RAY), WAND(NULL, "oak", 0, 0), WAND(NULL, "ebony", 0, 0), WAND(NULL, "runed", 0, 0), #define RING(name,stone,spec) { name, stone, NULL, 0, 0,\ RING_SYM, 0, 0, 1, spec, 0, 0 } RING("adornment", "engagement", 0), RING("teleportation", "wooden", 0), RING("regeneration", "black onyx", 0), RING("searching", "topaz", 0), RING("see invisible", "pearl", 0), RING("stealth", "sapphire", 0), RING("levitation", "moonstone", 0), RING("poison resistance", "agate", 0), RING("aggravate monster", "tiger eye", 0), RING("hunger", "shining", 0), RING("fire resistance", "gold", 0), RING("cold resistance", "copper", 0), RING("protection from shape changers", "diamond", 0), RING("conflict", "jade", 0), RING("gain strength", "ruby", SPEC), RING("increase damage", "silver", SPEC), RING("protection", "granite", SPEC), RING("warning", "wire", 0), RING("teleport control", "iron", 0), RING(NULL, "ivory", 0), RING(NULL, "blackened", 0), /* gems ************************************************************/ #define GEM(name,color,prob,gval) { name, color, NULL, 0, 1,\ GEM_SYM, prob, 0, 1, 0, 0, gval } GEM("diamond", "blue", 1, 4000), GEM("ruby", "red", 1, 3500), GEM("sapphire", "blue", 1, 3000), GEM("emerald", "green", 1, 2500), GEM("turquoise", "green", 1, 2000), GEM("aquamarine", "blue", 1, 1500), GEM("tourmaline", "green", 1, 1000), GEM("topaz", "yellow", 1, 900), GEM("opal", "yellow", 1, 800), GEM("garnet", "dark", 1, 700), GEM("amethyst", "violet", 2, 650), GEM("agate", "green", 2, 600), GEM("onyx", "white", 2, 550), GEM("jasper", "yellowish brown", 2, 500), GEM("jade", "green", 2, 450), GEM("worthless piece of blue glass", "blue", 20, 0), GEM("worthless piece of red glass", "red", 20, 0), GEM("worthless piece of yellow glass", "yellow", 20, 0), GEM("worthless piece of green glass", "green", 20, 0), { NULL, NULL, NULL, 0, 0, ILLOBJ_SYM, 0, 0, 0, 0, 0, 0 } }; const char obj_symbols[] = { ILLOBJ_SYM, AMULET_SYM, FOOD_SYM, WEAPON_SYM, TOOL_SYM, BALL_SYM, CHAIN_SYM, ROCK_SYM, ARMOR_SYM, POTION_SYM, SCROLL_SYM, WAND_SYM, RING_SYM, GEM_SYM, 0 }; int bases[sizeof(obj_symbols)]; #endif /* _DEF_OBJECTS_H_ */ bsd-games-2.17/hack/hack.timeout.c0000664000175000017500000001115207767741711015465 0ustar jsm28jsm28/* $NetBSD: hack.timeout.c,v 1.6 2003/04/02 18:36:41 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.timeout.c,v 1.6 2003/04/02 18:36:41 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" void timeout() { struct prop *upp; if (Stoned) stoned_dialogue(); for (upp = u.uprops; upp < u.uprops + SIZE(u.uprops); upp++) if ((upp->p_flgs & TIMEOUT) && !--upp->p_flgs) { if (upp->p_tofn) (*upp->p_tofn) (); else switch (upp - u.uprops) { case STONED: killer = "cockatrice"; done("died"); break; case SICK: pline("You die because of food poisoning."); killer = u.usick_cause; done("died"); break; case FAST: pline("You feel yourself slowing down."); break; case CONFUSION: pline("You feel less confused now."); break; case BLIND: pline("You can see again."); setsee(); break; case INVIS: on_scr(u.ux, u.uy); pline("You are no longer invisible."); break; case WOUNDED_LEGS: heal_legs(); break; } } } /* He is being petrified - dialogue by inmet!tower */ const char *const stoned_texts[] = { "You are slowing down.",/* 5 */ "Your limbs are stiffening.", /* 4 */ "Your limbs have turned to stone.", /* 3 */ "You have turned to stone.", /* 2 */ "You are a statue." /* 1 */ }; void stoned_dialogue() { long i = (Stoned & TIMEOUT); if (i > 0 && i <= SIZE(stoned_texts)) pline(stoned_texts[SIZE(stoned_texts) - i]); if (i == 5) Fast = 0; if (i == 3) nomul(-3); } bsd-games-2.17/hack/hack.engrave.c0000664000175000017500000002445607767741711015441 0ustar jsm28jsm28/* $NetBSD: hack.engrave.c,v 1.6 2003/04/02 18:36:36 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.engrave.c,v 1.6 2003/04/02 18:36:36 jsm Exp $"); #endif /* not lint */ #include #include "hack.h" #include "extern.h" struct engr { struct engr *nxt_engr; char *engr_txt; xchar engr_x, engr_y; unsigned engr_lth; /* for save & restore; not length of * text */ long engr_time; /* moment engraving was (will be) * finished */ xchar engr_type; #define DUST 1 #define ENGRAVE 2 #define BURN 3 } *head_engr; struct engr * engr_at(x, y) xchar x, y; { struct engr *ep = head_engr; while (ep) { if (x == ep->engr_x && y == ep->engr_y) return (ep); ep = ep->nxt_engr; } return ((struct engr *) 0); } int sengr_at(s, x, y) const char *s; xchar x, y; { struct engr *ep = engr_at(x, y); char *t; int n; if (ep && ep->engr_time <= moves) { t = ep->engr_txt; /* if(!strcmp(s,t)) return(1); */ n = strlen(s); while (*t) { if (!strncmp(s, t, n)) return (1); t++; } } return (0); } void u_wipe_engr(cnt) int cnt; { if (!u.uswallow && !Levitation) wipe_engr_at(u.ux, u.uy, cnt); } void wipe_engr_at(x, y, cnt) xchar x, y, cnt; { struct engr *ep = engr_at(x, y); int lth, pos; char ch; if (ep) { if ((ep->engr_type != DUST) || Levitation) { cnt = rn2(1 + 50 / (cnt + 1)) ? 0 : 1; } lth = strlen(ep->engr_txt); if (lth && cnt > 0) { while (cnt--) { pos = rn2(lth); if ((ch = ep->engr_txt[pos]) == ' ') continue; ep->engr_txt[pos] = (ch != '?') ? '?' : ' '; } } while (lth && ep->engr_txt[lth - 1] == ' ') ep->engr_txt[--lth] = 0; while (ep->engr_txt[0] == ' ') ep->engr_txt++; if (!ep->engr_txt[0]) del_engr(ep); } } void read_engr_at(x, y) int x, y; { struct engr *ep = engr_at(x, y); if (ep && ep->engr_txt[0]) { switch (ep->engr_type) { case DUST: pline("Something is written here in the dust."); break; case ENGRAVE: pline("Something is engraved here on the floor."); break; case BURN: pline("Some text has been burned here in the floor."); break; default: impossible("Something is written in a very strange way."); } pline("You read: \"%s\".", ep->engr_txt); } } void make_engr_at(x, y, s) int x, y; const char *s; { struct engr *ep; if ((ep = engr_at(x, y)) != NULL) del_engr(ep); ep = (struct engr *) alloc((unsigned) (sizeof(struct engr) + strlen(s) + 1)); ep->nxt_engr = head_engr; head_engr = ep; ep->engr_x = x; ep->engr_y = y; ep->engr_txt = (char *) (ep + 1); (void) strcpy(ep->engr_txt, s); ep->engr_time = 0; ep->engr_type = DUST; ep->engr_lth = strlen(s) + 1; } int doengrave() { int len; char *sp; struct engr *ep, *oep = engr_at(u.ux, u.uy); char buf[BUFSZ]; xchar type; int spct; /* number of leading spaces */ struct obj *otmp; multi = 0; if (u.uswallow) { pline("You're joking. Hahaha!"); /* riv05!a3 */ return (0); } /* one may write with finger, weapon or wand */ otmp = getobj("#-)/", "write with"); if (!otmp) return (0); if (otmp == &zeroobj) otmp = 0; if (otmp && otmp->otyp == WAN_FIRE && otmp->spe) { type = BURN; otmp->spe--; } else { /* first wield otmp */ if (otmp != uwep) { if (uwep && uwep->cursed) { /* Andreas Bormann */ pline("Since your weapon is welded to your hand,"); pline("you use the %s.", aobjnam(uwep, (char *) 0)); otmp = uwep; } else { if (!otmp) pline("You are now empty-handed."); else if (otmp->cursed) pline("The %s %s to your hand!", aobjnam(otmp, "weld"), (otmp->quan == 1) ? "itself" : "themselves"); else pline("You now wield %s.", doname(otmp)); setuwep(otmp); } } if (!otmp) type = DUST; else if (otmp->otyp == DAGGER || otmp->otyp == TWO_HANDED_SWORD || otmp->otyp == CRYSKNIFE || otmp->otyp == LONG_SWORD || otmp->otyp == AXE) { type = ENGRAVE; if ((int) otmp->spe <= -3) { type = DUST; pline("Your %s too dull for engraving.", aobjnam(otmp, "are")); if (oep && oep->engr_type != DUST) return (1); } } else type = DUST; } if (Levitation && type != BURN) { /* riv05!a3 */ pline("You can't reach the floor!"); return (1); } if (oep && oep->engr_type == DUST) { pline("You wipe out the message that was written here."); del_engr(oep); oep = 0; } if (type == DUST && oep) { pline("You cannot wipe out the message that is %s in the rock.", (oep->engr_type == BURN) ? "burned" : "engraved"); return (1); } pline("What do you want to %s on the floor here? ", (type == ENGRAVE) ? "engrave" : (type == BURN) ? "burn" : "write"); getlin(buf); clrlin(); spct = 0; sp = buf; while (*sp == ' ') spct++, sp++; len = strlen(sp); if (!len || *buf == '\033') { if (type == BURN) otmp->spe++; return (0); } switch (type) { case DUST: case BURN: if (len > 15) { multi = -(len / 10); nomovemsg = "You finished writing."; } break; case ENGRAVE: /* here otmp != 0 */ { int len2 = (otmp->spe + 3) * 2 + 1; pline("Your %s dull.", aobjnam(otmp, "get")); if (len2 < len) { len = len2; sp[len] = 0; otmp->spe = -3; nomovemsg = "You cannot engrave more."; } else { otmp->spe -= len / 2; nomovemsg = "You finished engraving."; } multi = -len; } break; } if (oep) len += strlen(oep->engr_txt) + spct; ep = (struct engr *) alloc((unsigned) (sizeof(struct engr) + len + 1)); ep->nxt_engr = head_engr; head_engr = ep; ep->engr_x = u.ux; ep->engr_y = u.uy; sp = (char *) (ep + 1); /* (char *)ep + sizeof(struct engr) */ ep->engr_txt = sp; if (oep) { (void) strcpy(sp, oep->engr_txt); (void) strcat(sp, buf); del_engr(oep); } else (void) strcpy(sp, buf); ep->engr_lth = len + 1; ep->engr_type = type; ep->engr_time = moves - multi; /* kludge to protect pline against excessively long texts */ if (len > BUFSZ - 20) sp[BUFSZ - 20] = 0; return (1); } void save_engravings(fd) int fd; { struct engr *ep = head_engr; while (ep) { if (!ep->engr_lth || !ep->engr_txt[0]) { ep = ep->nxt_engr; continue; } bwrite(fd, (char *) &(ep->engr_lth), sizeof(ep->engr_lth)); bwrite(fd, (char *) ep, sizeof(struct engr) + ep->engr_lth); ep = ep->nxt_engr; } bwrite(fd, (char *) nul, sizeof(unsigned)); head_engr = 0; } void rest_engravings(fd) int fd; { struct engr *ep; unsigned lth; head_engr = 0; while (1) { mread(fd, (char *) <h, sizeof(unsigned)); if (lth == 0) return; ep = (struct engr *) alloc(sizeof(struct engr) + lth); mread(fd, (char *) ep, sizeof(struct engr) + lth); ep->nxt_engr = head_engr; ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */ head_engr = ep; } } void del_engr(ep) struct engr *ep; { struct engr *ept; if (ep == head_engr) head_engr = ep->nxt_engr; else { for (ept = head_engr; ept; ept = ept->nxt_engr) { if (ept->nxt_engr == ep) { ept->nxt_engr = ep->nxt_engr; goto fnd; } } impossible("Error in del_engr?"); return; fnd: ; } free((char *) ep); } bsd-games-2.17/hack/hack.rumors.c0000664000175000017500000001132407767741711015327 0ustar jsm28jsm28/* $NetBSD: hack.rumors.c,v 1.5 2003/04/02 18:36:39 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.rumors.c,v 1.5 2003/04/02 18:36:39 jsm Exp $"); #endif /* not lint */ #include "hack.h" /* for RUMORFILE and BSD (strchr) */ #include "extern.h" #define CHARSZ 8 /* number of bits in a char */ int n_rumors = 0; int n_used_rumors = -1; char *usedbits; void init_rumors(rumf) FILE *rumf; { int i; n_used_rumors = 0; while (skipline(rumf)) n_rumors++; rewind(rumf); i = n_rumors / CHARSZ; usedbits = (char *) alloc((unsigned) (i + 1)); for (; i >= 0; i--) usedbits[i] = 0; } int skipline(rumf) FILE *rumf; { char line[COLNO]; while (1) { if (!fgets(line, sizeof(line), rumf)) return (0); if (strchr(line, '\n')) return (1); } } void outline(rumf) FILE *rumf; { char line[COLNO]; char *ep; if (!fgets(line, sizeof(line), rumf)) return; if ((ep = strchr(line, '\n')) != 0) *ep = 0; pline("This cookie has a scrap of paper inside! It reads: "); pline(line); } void outrumor() { int rn, i; FILE *rumf; if (n_rumors <= n_used_rumors || (rumf = fopen(RUMORFILE, "r")) == (FILE *) 0) return; if (n_used_rumors < 0) init_rumors(rumf); if (!n_rumors) goto none; rn = rn2(n_rumors - n_used_rumors); i = 0; while (rn || used(i)) { (void) skipline(rumf); if (!used(i)) rn--; i++; } usedbits[i / CHARSZ] |= (1 << (i % CHARSZ)); n_used_rumors++; outline(rumf); none: (void) fclose(rumf); } int used(i) int i; { return (usedbits[i / CHARSZ] & (1 << (i % CHARSZ))); } bsd-games-2.17/hack/hack.6.in0000664000175000017500000001605510057361272014321 0ustar jsm28jsm28.\" $NetBSD: hack.6,v 1.14 2004/06/01 10:10:06 wiz Exp $ -*- nroff -*- .\" .\" Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, .\" Amsterdam .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions are .\" met: .\" .\" - Redistributions of source code must retain the above copyright notice, .\" this list of conditions and the following disclaimer. .\" .\" - Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" - Neither the name of the Stichting Centrum voor Wiskunde en .\" Informatica, nor the names of its contributors may be used to endorse or .\" promote products derived from this software without specific prior .\" written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS .\" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A .\" PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER .\" OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, .\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, .\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR .\" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF .\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING .\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" .\" Copyright (c) 1982 Jay Fenlason .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY .\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL .\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, .\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, .\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; .\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .Dd March 31, 1985 .Dt HACK 6 .Os .Sh NAME .Nm hack .Nd exploring The Dungeons of Doom .Sh SYNOPSIS .Nm .Op Fl d Ar directory .Op Fl n .Op Fl u Ar playername .Nm .Op Fl d Ar directory .Op Fl s .Op Fl X .Op Ar playername ... .Sh DESCRIPTION .Nm is a display oriented dungeons \*[Am] dragons-like game. Both display and command structure resemble rogue. (For a game with the same structure but entirely different display - a real cave instead of dull rectangles - try Quest.) .Pp To get started you really only need to know two commands. The command .Ic \&? will give you a list of the available commands and the command .Ic / will identify the things you see on the screen. .Pp To win the game (as opposed to merely playing to beat other people's high scores) you must locate the Amulet of Yendor which is somewhere below the 20th level of the dungeon and get it out. Nobody has achieved this yet and if somebody does, he will probably go down in history as a hero among heroes. .Pp When the game ends, either by your death, when you quit, or if you escape from the caves, .Nm will give you (a fragment of) the list of top scorers. The scoring is based on many aspects of your behavior but a rough estimate is obtained by taking the amount of gold you've found in the cave plus four times your (real) experience. Precious stones may be worth a lot of gold when brought to the exit. There is a 10% penalty for getting yourself killed. .Pp The administration of the game is kept in the directory specified with the .Fl d option, or, if no such option is given, in the directory specified by the environment variable .Ev HACKDIR , or, if no such variable exists, in the current directory. This same directory contains several auxiliary files such as lockfiles and the list of topscorers and a subdirectory .Pa save where games are saved. The game administrator may however choose to install hack with a fixed playing ground, usually .Pa @hack_dir@ . .Pp The .Fl n option suppresses printing of the news. .Pp The .Fl u .Ar playername option supplies the answer to the question "Who are you?". When .Ar playername has as suffix one of .Em -T , .Em -S , .Em -K , .Em -F , .Em -C , or .Em -W , then this supplies the answer to the question "What kind of character ... ?". .Pp The .Fl s option will print out the list of your scores. It may be followed by arguments .Fl X where X is one of the letters C, F, K, S, T, W to print the scores of Cavemen, Fighters, Knights, Speleologists, Tourists or Wizards. It may also be followed by one or more player names to print the scores of the players mentioned. .Sh AUTHORS Jay Fenlason (+ Kenny Woodland, Mike Thome and Jon Payne) wrote the original hack, very much like rogue (but full of bugs). .br Andries Brouwer continuously deformed their sources into the current version - in fact an entirely different game. .Sh FILES .Bl -tag -width 24n -compact .It Pa hack The hack program. .It Pa data, rumors Data files used by hack. .It Pa help, hh Help data files. .It Pa record The list of topscorers. .It Pa save A subdirectory containing the saved games. .It Pa bones_dd Descriptions of the ghost and belongings of a deceased adventurer. .It Pa xlock.dd Description of a dungeon level. .It Pa safelock Lock file for xlock. .It Pa record_lock Lock file for record. .El .Sh ENVIRONMENT .Bl -tag -width 24n -compact .It Ev USER No or Ev LOGNAME Your login name. .It Ev HOME Your home directory. .It Ev SHELL Your shell. .It Ev TERM The type of your terminal. .It Ev HACKPAGER, PAGER Pager used instead of default pager. .It Ev MAIL Mailbox file. .It Ev MAILREADER Reader used instead of default (probably .Pa /usr/bin/mail ) . .It Ev HACKDIR Playground. .It Ev HACKOPTIONS String predefining several hack options (see help file). .El .Pp Several other environment variables are used in debugging (wizard) mode, like .Ev GENOCIDED , .Ev INVENT , .Ev MAGIC and .Ev SHOPTYPE . .Sh BUGS Probably infinite. Mail complaints to mcvax!aeb . bsd-games-2.17/hack/hack.rip.c0000664000175000017500000001131707767741711014574 0ustar jsm28jsm28/* $NetBSD: hack.rip.c,v 1.7 2003/04/02 18:36:39 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.rip.c,v 1.7 2003/04/02 18:36:39 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" static const char *riptop = "\ ----------\n\ / \\\n\ / REST \\\n\ / IN \\\n\ / PEACE \\\n\ / \\"; static const char *ripmid = " | %*s%*s |\n"; static const char *ripbot = "\ *| * * * | *\n\ _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______"; void outrip() { char buf[BUFSZ]; cls(); curs(1, 8); puts(riptop); (void) strcpy(buf, plname); buf[16] = 0; center(6, buf); (void) sprintf(buf, "%ld AU", u.ugold); center(7, buf); (void) sprintf(buf, "killed by%s", !strncmp(killer, "the ", 4) ? "" : !strcmp(killer, "starvation") ? "" : strchr(vowels, *killer) ? " an" : " a"); center(8, buf); (void) strcpy(buf, killer); { int i1; if ((i1 = strlen(buf)) > 16) { int i, i0; i0 = i1 = 0; for (i = 0; i <= 16; i++) if (buf[i] == ' ') i0 = i, i1 = i + 1; if (!i0) i0 = i1 = 16; buf[i1 + 16] = 0; buf[i0] = 0; } center(9, buf); center(10, buf + i1); } (void) sprintf(buf, "%4d", getyear()); center(11, buf); puts(ripbot); getret(); } void center(line, text) int line __attribute__((__unused__)); char *text; { int n = strlen(text) / 2; printf(ripmid, 8 + n, text, 8 - n, ""); } bsd-games-2.17/hack/hack.zap.c0000664000175000017500000004401510005547567014565 0ustar jsm28jsm28/* $NetBSD: hack.zap.c,v 1.7 2004/01/27 20:30:29 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.zap.c,v 1.7 2004/01/27 20:30:29 jsm Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" const char *const fl[] = { "magic missile", "bolt of fire", "sleep ray", "bolt of cold", "death ray" }; /* Routines for IMMEDIATE wands. */ /* bhitm: monster mtmp was hit by the effect of wand otmp */ void bhitm(mtmp, otmp) struct monst *mtmp; struct obj *otmp; { wakeup(mtmp); switch (otmp->otyp) { case WAN_STRIKING: if (u.uswallow || rnd(20) < 10 + mtmp->data->ac) { int tmp = d(2, 12); hit("wand", mtmp, exclam(tmp)); mtmp->mhp -= tmp; if (mtmp->mhp < 1) killed(mtmp); } else miss("wand", mtmp); break; case WAN_SLOW_MONSTER: mtmp->mspeed = MSLOW; break; case WAN_SPEED_MONSTER: mtmp->mspeed = MFAST; break; case WAN_UNDEAD_TURNING: if (strchr(UNDEAD, mtmp->data->mlet)) { mtmp->mhp -= rnd(8); if (mtmp->mhp < 1) killed(mtmp); else mtmp->mflee = 1; } break; case WAN_POLYMORPH: if (newcham(mtmp, &mons[rn2(CMNUM)])) objects[otmp->otyp].oc_name_known = 1; break; case WAN_CANCELLATION: mtmp->mcan = 1; break; case WAN_TELEPORTATION: rloc(mtmp); break; case WAN_MAKE_INVISIBLE: mtmp->minvis = 1; break; #ifdef WAN_PROBING case WAN_PROBING: mstatusline(mtmp); break; #endif /* WAN_PROBING */ default: impossible("What an interesting wand (%u)", otmp->otyp); } } int bhito(obj, otmp) /* object obj was hit by the effect of wand * otmp */ struct obj *obj, *otmp; /* returns TRUE if sth was done */ { int res = TRUE; if (obj == uball || obj == uchain) res = FALSE; else switch (otmp->otyp) { case WAN_POLYMORPH: /* * preserve symbol and quantity, but turn rocks into * gems */ mkobj_at((obj->otyp == ROCK || obj->otyp == ENORMOUS_ROCK) ? GEM_SYM : obj->olet, obj->ox, obj->oy)->quan = obj->quan; delobj(obj); break; case WAN_STRIKING: if (obj->otyp == ENORMOUS_ROCK) fracture_rock(obj); else res = FALSE; break; case WAN_CANCELLATION: if (obj->spe && obj->olet != AMULET_SYM) { obj->known = 0; obj->spe = 0; } break; case WAN_TELEPORTATION: rloco(obj); break; case WAN_MAKE_INVISIBLE: obj->oinvis = 1; break; case WAN_UNDEAD_TURNING: res = revive(obj); break; case WAN_SLOW_MONSTER: /* no effect on objects */ case WAN_SPEED_MONSTER: #ifdef WAN_PROBING case WAN_PROBING: #endif /* WAN_PROBING */ res = FALSE; break; default: impossible("What an interesting wand (%u)", otmp->otyp); } return (res); } int dozap() { struct obj *obj; xchar zx, zy; obj = getobj("/", "zap"); if (!obj) return (0); if (obj->spe < 0 || (obj->spe == 0 && rn2(121))) { pline("Nothing Happens."); return (1); } if (obj->spe == 0) pline("You wrest one more spell from the worn-out wand."); if (!(objects[obj->otyp].bits & NODIR) && !getdir(1)) return (1); /* make him pay for knowing !NODIR */ obj->spe--; if (objects[obj->otyp].bits & IMMEDIATE) { if (u.uswallow) bhitm(u.ustuck, obj); else if (u.dz) { if (u.dz > 0) { struct obj *otmp = o_at(u.ux, u.uy); if (otmp) (void) bhito(otmp, obj); } } else (void) bhit(u.dx, u.dy, rn1(8, 6), 0, bhitm, bhito, obj); } else { switch (obj->otyp) { case WAN_LIGHT: litroom(TRUE); break; case WAN_SECRET_DOOR_DETECTION: if (!findit()) return (1); break; case WAN_CREATE_MONSTER: { int cnt = 1; if (!rn2(23)) cnt += rn2(7) + 1; while (cnt--) (void) makemon((struct permonst *) 0, u.ux, u.uy); } break; case WAN_WISHING: { char buf[BUFSZ]; struct obj *otmp; if (u.uluck + rn2(5) < 0) { pline("Unfortunately, nothing happens."); break; } pline("You may wish for an object. What do you want? "); getlin(buf); if (buf[0] == '\033') buf[0] = 0; otmp = readobjnam(buf); otmp = addinv(otmp); prinv(otmp); break; } case WAN_DIGGING: /* * Original effect (approximately): from CORR: dig * until we pierce a wall from ROOM: piece wall and * dig until we reach an ACCESSIBLE place. Currently: * dig for digdepth positions; also down on request * of Lennart Augustsson. */ { struct rm *room; int digdepth; if (u.uswallow) { struct monst *mtmp = u.ustuck; pline("You pierce %s's stomach wall!", monnam(mtmp)); mtmp->mhp = 1; /* almost dead */ unstuck(mtmp); mnexto(mtmp); break; } if (u.dz) { if (u.dz < 0) { pline("You loosen a rock from the ceiling."); pline("It falls on your head!"); losehp(1, "falling rock"); mksobj_at(ROCK, u.ux, u.uy); fobj->quan = 1; stackobj(fobj); if (Invisible) newsym(u.ux, u.uy); } else { dighole(); } break; } zx = u.ux + u.dx; zy = u.uy + u.dy; digdepth = 8 + rn2(18); Tmp_at(-1, '*'); /* open call */ while (--digdepth >= 0) { if (!isok(zx, zy)) break; room = &levl[zx][zy]; Tmp_at(zx, zy); if (!xdnstair) { if (zx < 3 || zx > COLNO - 3 || zy < 3 || zy > ROWNO - 3) break; if (room->typ == HWALL || room->typ == VWALL) { room->typ = ROOM; break; } } else if (room->typ == HWALL || room->typ == VWALL || room->typ == SDOOR || room->typ == LDOOR) { room->typ = DOOR; digdepth -= 2; } else if (room->typ == SCORR || !room->typ) { room->typ = CORR; digdepth--; } mnewsym(zx, zy); zx += u.dx; zy += u.dy; } mnewsym(zx, zy); /* not always necessary */ Tmp_at(-1, -1); /* closing call */ break; } default: buzz((int) obj->otyp - WAN_MAGIC_MISSILE, u.ux, u.uy, u.dx, u.dy); break; } if (!objects[obj->otyp].oc_name_known) { objects[obj->otyp].oc_name_known = 1; more_experienced(0, 10); } } return (1); } const char * exclam(force) int force; { /* force == 0 occurs e.g. with sleep ray */ /* * note that large force is usual with wands so that !! would require * information about hand/weapon/wand */ return ((force < 0) ? "?" : (force <= 4) ? "." : "!"); } void hit(str, mtmp, force) const char *str; struct monst *mtmp; const char *force; /* usually either "." or "!" */ { if (!cansee(mtmp->mx, mtmp->my)) pline("The %s hits it.", str); else pline("The %s hits %s%s", str, monnam(mtmp), force); } void miss(str, mtmp) const char *str; struct monst *mtmp; { if (!cansee(mtmp->mx, mtmp->my)) pline("The %s misses it.", str); else pline("The %s misses %s.", str, monnam(mtmp)); } /* * bhit: called when a weapon is thrown (sym = obj->olet) or when an * IMMEDIATE wand is zapped (sym = 0); the weapon falls down at end of range * or when a monster is hit; the monster is returned, and bhitpos is set to * the final position of the weapon thrown; the ray of a wand may affect * several objects and monsters on its path - for each of these an argument * function is called. */ /* check !u.uswallow before calling bhit() */ struct monst * bhit(ddx, ddy, range, sym, fhitm, fhito, obj) int ddx, ddy, range; /* direction and range */ char sym; /* symbol displayed on path */ /* fns called when mon/obj hit */ void (*fhitm)(struct monst *, struct obj *); int (*fhito)(struct obj *, struct obj *); struct obj *obj; /* 2nd arg to fhitm/fhito */ { struct monst *mtmp; struct obj *otmp; int typ; bhitpos.x = u.ux; bhitpos.y = u.uy; if (sym) tmp_at(-1, sym);/* open call */ while (range-- > 0) { bhitpos.x += ddx; bhitpos.y += ddy; typ = levl[bhitpos.x][bhitpos.y].typ; if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != NULL) { if (sym) { tmp_at(-1, -1); /* close call */ return (mtmp); } (*fhitm) (mtmp, obj); range -= 3; } if (fhito && (otmp = o_at(bhitpos.x, bhitpos.y))) { if ((*fhito) (otmp, obj)) range--; } if (!ZAP_POS(typ)) { bhitpos.x -= ddx; bhitpos.y -= ddy; break; } if (sym) tmp_at(bhitpos.x, bhitpos.y); } /* leave last symbol unless in a pool */ if (sym) tmp_at(-1, (levl[bhitpos.x][bhitpos.y].typ == POOL) ? -1 : 0); return (0); } struct monst * boomhit(int dx, int dy) { int i, ct; struct monst *mtmp; char sym = ')'; bhitpos.x = u.ux; bhitpos.y = u.uy; for (i = 0; i < 8; i++) if (xdir[i] == dx && ydir[i] == dy) break; tmp_at(-1, sym); /* open call */ for (ct = 0; ct < 10; ct++) { if (i == 8) i = 0; sym = ')' + '(' - sym; tmp_at(-2, sym);/* change let call */ dx = xdir[i]; dy = ydir[i]; bhitpos.x += dx; bhitpos.y += dy; if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != NULL) { tmp_at(-1, -1); return (mtmp); } if (!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ)) { bhitpos.x -= dx; bhitpos.y -= dy; break; } if (bhitpos.x == u.ux && bhitpos.y == u.uy) { /* ct == 9 */ if (rn2(20) >= 10 + u.ulevel) { /* we hit ourselves */ (void) thitu(10, rnd(10), "boomerang"); break; } else {/* we catch it */ tmp_at(-1, -1); pline("Skillfully, you catch the boomerang."); return (&youmonst); } } tmp_at(bhitpos.x, bhitpos.y); if (ct % 5 != 0) i++; } tmp_at(-1, -1); /* do not leave last symbol */ return (0); } char dirlet(dx, dy) int dx, dy; { return (dx == dy) ? '\\' : (dx && dy) ? '/' : dx ? '-' : '|'; } /* type == -1: monster spitting fire at you */ /* type == -1,-2,-3: bolts sent out by wizard */ /* called with dx = dy = 0 with vertical bolts */ void buzz(type, sx, sy, dx, dy) int type; xchar sx, sy; int dx, dy; { int abstype = abs(type); const char *fltxt = (type == -1) ? "blaze of fire" : fl[abstype]; struct rm *lev; xchar range; struct monst *mon; if (u.uswallow) { int tmp; if (type < 0) return; tmp = zhit(u.ustuck, type); pline("The %s rips into %s%s", fltxt, monnam(u.ustuck), exclam(tmp)); return; } if (type < 0) pru(); range = rn1(7, 7); Tmp_at(-1, dirlet(dx, dy)); /* open call */ while (range-- > 0) { sx += dx; sy += dy; if ((lev = &levl[sx][sy])->typ) Tmp_at(sx, sy); else { int bounce = 0; if (cansee(sx - dx, sy - dy)) pline("The %s bounces!", fltxt); if (ZAP_POS(levl[sx][sy - dy].typ)) bounce = 1; if (ZAP_POS(levl[sx - dx][sy].typ)) { if (!bounce || rn2(2)) bounce = 2; } switch (bounce) { case 0: dx = -dx; dy = -dy; continue; case 1: dy = -dy; sx -= dx; break; case 2: dx = -dx; sy -= dy; break; } Tmp_at(-2, dirlet(dx, dy)); continue; } if (lev->typ == POOL && abstype == 1 /* fire */ ) { range -= 3; lev->typ = ROOM; if (cansee(sx, sy)) { mnewsym(sx, sy); pline("The water evaporates."); } else pline("You hear a hissing sound."); } if ((mon = m_at(sx, sy)) && (type != -1 || mon->data->mlet != 'D')) { wakeup(mon); if (rnd(20) < 18 + mon->data->ac) { int tmp = zhit(mon, abstype); if (mon->mhp < 1) { if (type < 0) { if (cansee(mon->mx, mon->my)) pline("%s is killed by the %s!", Monnam(mon), fltxt); mondied(mon); } else killed(mon); } else hit(fltxt, mon, exclam(tmp)); range -= 2; } else miss(fltxt, mon); } else if (sx == u.ux && sy == u.uy) { nomul(0); if (rnd(20) < 18 + u.uac) { int dam = 0; range -= 2; pline("The %s hits you!", fltxt); switch (abstype) { case 0: dam = d(2, 6); break; case 1: if (Fire_resistance) pline("You don't feel hot!"); else dam = d(6, 6); if (!rn2(3)) burn_scrolls(); break; case 2: nomul(-rnd(25)); /* sleep ray */ break; case 3: if (Cold_resistance) pline("You don't feel cold!"); else dam = d(6, 6); break; case 4: u.uhp = -1; } losehp(dam, fltxt); } else pline("The %s whizzes by you!", fltxt); stop_occupation(); } if (!ZAP_POS(lev->typ)) { int bounce = 0, rmn; if (cansee(sx, sy)) pline("The %s bounces!", fltxt); range--; if (!dx || !dy || !rn2(20)) { dx = -dx; dy = -dy; } else { if (ZAP_POS(rmn = levl[sx][sy - dy].typ) && (IS_ROOM(rmn) || ZAP_POS(levl[sx + dx][sy - dy].typ))) bounce = 1; if (ZAP_POS(rmn = levl[sx - dx][sy].typ) && (IS_ROOM(rmn) || ZAP_POS(levl[sx - dx][sy + dy].typ))) if (!bounce || rn2(2)) bounce = 2; switch (bounce) { case 0: dy = -dy; dx = -dx; break; case 1: dy = -dy; break; case 2: dx = -dx; break; } Tmp_at(-2, dirlet(dx, dy)); } } } Tmp_at(-1, -1); } int zhit(mon, type) /* returns damage to mon */ struct monst *mon; int type; { int tmp = 0; switch (type) { case 0: /* magic missile */ tmp = d(2, 6); break; case -1: /* Dragon blazing fire */ case 1: /* fire */ if (strchr("Dg", mon->data->mlet)) break; tmp = d(6, 6); if (strchr("YF", mon->data->mlet)) tmp += 7; break; case 2: /* sleep */ mon->mfroz = 1; break; case 3: /* cold */ if (strchr("YFgf", mon->data->mlet)) break; tmp = d(6, 6); if (mon->data->mlet == 'D') tmp += 7; break; case 4: /* death */ if (strchr(UNDEAD, mon->data->mlet)) break; tmp = mon->mhp + 1; break; } mon->mhp -= tmp; return (tmp); } #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\ ? 'a' + (otyp - DEAD_ACID_BLOB)\ : '@' + (otyp - DEAD_HUMAN)) int revive(obj) struct obj *obj; { struct monst *mtmp = NULL; if (obj->olet == FOOD_SYM && obj->otyp > CORPSE) { /* do not (yet) revive shopkeepers */ /* * Note: this might conceivably produce two monsters at the * same position - strange, but harmless */ mtmp = mkmon_at(CORPSE_I_TO_C(obj->otyp), obj->ox, obj->oy); delobj(obj); } return (!!mtmp); /* TRUE if some monster created */ } void rloco(obj) struct obj *obj; { int tx, ty, otx, oty; otx = obj->ox; oty = obj->oy; do { tx = rn1(COLNO - 3, 2); ty = rn2(ROWNO); } while (!goodpos(tx, ty)); obj->ox = tx; obj->oy = ty; if (cansee(otx, oty)) newsym(otx, oty); } void fracture_rock(obj) /* fractured by pick-axe or wand of striking */ struct obj *obj; /* no texts here! */ { /* unpobj(obj); */ obj->otyp = ROCK; obj->quan = 7 + rn2(60); obj->owt = weight(obj); obj->olet = WEAPON_SYM; if (cansee(obj->ox, obj->oy)) prl(obj->ox, obj->oy); } void burn_scrolls() { struct obj *obj, *obj2; int cnt = 0; for (obj = invent; obj; obj = obj2) { obj2 = obj->nobj; if (obj->olet == SCROLL_SYM) { cnt++; useup(obj); } } if (cnt > 1) { pline("Your scrolls catch fire!"); losehp(cnt, "burning scrolls"); } else if (cnt) { pline("Your scroll catches fire!"); losehp(1, "burning scroll"); } } bsd-games-2.17/hack/hack.options.c0000664000175000017500000001762207775331303015471 0ustar jsm28jsm28/* $NetBSD: hack.options.c,v 1.7 2004/01/01 16:02:51 jsm Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, * Amsterdam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Stichting Centrum voor Wiskunde en * Informatica, nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1982 Jay Fenlason * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint __RCSID("$NetBSD: hack.options.c,v 1.7 2004/01/01 16:02:51 jsm Exp $"); #endif /* not lint */ #include #include #include "hack.h" #include "extern.h" void initoptions() { char *opts; flags.time = flags.nonews = flags.notombstone = flags.end_own = flags.standout = flags.nonull = FALSE; flags.no_rest_on_space = TRUE; flags.invlet_constant = TRUE; flags.end_top = 5; flags.end_around = 4; flags.female = FALSE; /* players are usually male */ if ((opts = getenv("HACKOPTIONS")) != NULL) parseoptions(opts, TRUE); } void parseoptions(opts, from_env) char *opts; boolean from_env; { char *op, *op2; unsigned num; boolean negated; if ((op = strchr(opts, ',')) != NULL) { *op++ = 0; parseoptions(op, from_env); } if ((op = strchr(opts, ' ')) != NULL) { op2 = op; while (*op++) if (*op != ' ') *op2++ = *op; } if (!*opts) return; negated = FALSE; while ((*opts == '!') || !strncmp(opts, "no", 2)) { if (*opts == '!') opts++; else opts += 2; negated = !negated; } if (!strncmp(opts, "standout", 8)) { flags.standout = !negated; return; } if (!strncmp(opts, "null", 3)) { flags.nonull = negated; return; } if (!strncmp(opts, "tombstone", 4)) { flags.notombstone = negated; return; } if (!strncmp(opts, "news", 4)) { flags.nonews = negated; return; } if (!strncmp(opts, "time", 4)) { flags.time = !negated; flags.botl = 1; return; } if (!strncmp(opts, "restonspace", 4)) { flags.no_rest_on_space = negated; return; } if (!strncmp(opts, "fixinv", 4)) { if (from_env) flags.invlet_constant = !negated; else pline("The fixinvlet option must be in HACKOPTIONS."); return; } if (!strncmp(opts, "male", 4)) { flags.female = negated; return; } if (!strncmp(opts, "female", 6)) { flags.female = !negated; return; } /* name:string */ if (!strncmp(opts, "name", 4)) { if (!from_env) { pline("The playername can be set only from HACKOPTIONS."); return; } op = strchr(opts, ':'); if (!op) goto bad; (void) strncpy(plname, op + 1, sizeof(plname) - 1); return; } /* endgame:5t[op] 5a[round] o[wn] */ if (!strncmp(opts, "endgame", 3)) { op = strchr(opts, ':'); if (!op) goto bad; op++; while (*op) { num = 1; if (digit(*op)) { num = atoi(op); while (digit(*op)) op++; } else if (*op == '!') { negated = !negated; op++; } switch (*op) { case 't': flags.end_top = num; break; case 'a': flags.end_around = num; break; case 'o': flags.end_own = !negated; break; default: goto bad; } while (letter(*++op)); if (*op == '/') op++; } return; } bad: if (!from_env) { if (!strncmp(opts, "help", 4)) { pline("%s%s%s", "To set options use `HACKOPTIONS=\"\"' in your environment, or ", "give the command 'O' followed by the line `' while playing. ", "Here is a list of