letter1() { int write_len; sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */ if (lcreat(mail600) < 0) { write_len = write(1,"can't write 600 letter\n",23); return(0); } lprcat("From: [email protected] (Ularn Revenue Service)\n"); lprcat("Subject: undeclared income\n"); lprcat("\n We heard you survived the caverns of Ularn. Let me be the"); lprcat("\nfirst to congratulate you on your success. It is quite a feat."); lprcat("\nIt must also have been very profitable for you."); lprcat("\n\n The Dungeon Master has informed us that you brought"); lprintf("\n%d gold piece%s back with you from your journey. As the", (long)c[GOLD], (c[GOLD]==1)?"":"s"); lprcat("\ncounty of Ularn is in dire need of funds, we have spared no time"); lprintf("\nin preparing your tax bill. You owe %d gold piece%s as", Taxes, (Taxes==1)?"":"s"); lprcat("\nof this notice, and is due within 5 days. Failure to pay will"); lprcat("\nmean penalties. Once again, congratulations. We look forward"); lprcat("\nto your future successful expeditions.\n"); lwclose(); return(1); }
static int letter3() { /* Prepare path */ sprintf(mail600, "/tmp#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 602 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" Count Endelford\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" You Bastard!\n"); lprcat("\n I heard (from sources) of your journey. Congratulations!"); lprcat("\nYou bastard! With several attempts I have yet to endure the"); lprcat(" caves,\nand you, a nobody, makes the journey! From this time"); lprcat(" onward, be warned\nupon our meeting you shall pay the price!\n"); lwclose(); return 1; }
static int letter2() { /* Prepare path */ sprintf(mail600, "/tmp/#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 601 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" His Majesty King Wilfred of Larndom\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" A Noble Deed\n"); lprcat("\n I have heard of your magnificent feat, and I, King Wilfred,"); lprcat("\nforthwith declare today to be a national holiday. Furthermore,"); lprcat("\nhence three days, Ye be invited to the castle to receive the"); lprcat("\nhonour of Kinght of the Realm. Upon thy name shall it be written..."); lprcat("\nBravery and courage be yours."); lprcat("\nMay you live in happiness forever...\n"); lwclose(); return 1; }
static int letter6() { /* Prepare path */ sprintf(mail600, "/tmp#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 605 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" The National Cancer Society of Larn\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" Hope\n"); lprcat("\n Congratulations on your successful expedition. We are sure much"); lprcat("\ncourage and dtermination were needed on your quest. There are"); lprcat("\nmany though, that could never hope to undertake such a journey"); lprcat("\ndue to an enfeebling disease -- cancer. We at the National"); lprcat("\nCancer Soceity of Larn wish to appeal to your philanthropy in"); lprcat("\norder to save many good people -- possibly even yourself in a few"); lprcat("\nyears from now. Much work needs to be done in researching this"); lprcat("\ndreaded disease, and you can help today. Could you please see it"); lprcat("\nin your heart to give generously? Your continued good health"); lprcat("\ncan be in your everlasting reward.\n"); lwclose(); return 1; }
static int letter5() { /* Prepare path */ sprintf(mail600, "/tmp/#%dmaill600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 604 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" St. Mary's Children's Home\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" These Poor Children\n"); lprcat("\n News of your great conquests has spread to all of Larndom."); lprcat("\nMight I have a moment of a great man's time. We here at St."); lprcat("\nMary's Children's Home are very poor, and many children are"); lprcat("\nstarving. Disease is widespread and very often fatal without"); lprcat("\ngood food. Could you possibly find it in your heart to help us"); lprcat("\nin out plight? Whatever you could give will help much."); lprcat("\n(your gift is tax deductible)\n"); lwclose(); return 1; }
static int letter4() { /* Prepare path */ sprintf(mail600, "/tmp/$%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 603 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" Mainair, Duke of Larnty\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" High Praise\n"); lprcat("\n With a certainty a hero I declare to be amongst us! A nod of"); lprcat("\nfavour I send to thee. Me thinks Count Endelford this day of"); lprcat("\nright breath'eth fire as a dragon of whom ye are slayer. I"); lprcat("\nyearn to behold his anger and jealously. Should ye choose to"); lprcat("\nunleash some of they wealth upon those whoe be unfortunate, I,"); lprcat("\nDuke Mainair, Shall equal thy gift also.\n"); lwclose(); return 1; }
/* * writeboard() Function to write the scoreboard from readboard()'s buffer * * returns -1 if unable to write the scoreboard, returns 0 if all is OK */ writeboard() { set_score_output(); if (lcreat(scorefile)<0) { lprcat("Can't write scoreboard\n"); lflush(); return(-1); } lwrite((char*)sco,sizeof(sco)); lwrite((char*)winr,sizeof(winr)); lwclose(); lcreat((char*)0); return(0); }
int getplid (char *nam) { int fd7, high = 999, no; char *p, *p2; char name[80]; if (havepid != -1) return (havepid); /* already did it */ lflush (); /* flush any pending I/O */ sprintf (name, "%s\n", nam); /* append a \n to name */ if (lopen (playerids) < 0) /* no file, make it */ { if ((fd7 = _creat (playerids, _S_IWRITE)) < 0) return (-1); /* can't make it */ _close (fd7); goto addone; /* now append new playerid record to file */ } for (;;) /* now search for the name in the player id file */ { p = lgetl (); if (p == NULL) break; /* EOF? */ no = atoi (p); /* the id # */ p2 = lgetl (); if (p2 == NULL) break; /* EOF? */ if (no > high) high = no; /* accumulate highest id # */ if (strcmp (p2, name) == 0) /* we found him */ { return (no); /* his id number */ } } lrclose (); /* if we get here, we didn't find him in the file -- put him there */ addone: if (lappend (playerids) < 0) return (-1); /* can't open file for append */ lprintf ("%d\n%s", (int) ++high, name); /* new id # and name */ lwclose (); lcreat ((char *) 0); /* re-open terminal channel */ return (high); }
letter3 () { int write_len; sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */ if (lcreat(mail600) < 0) { write_len = write(1,"can't write 600 letter\n",23); return(0); } lprcat("From: [email protected] (Count Endelford)\n"); lprintf("Subject: You %s\n!", sex?"Bastard":"Bitch"); lprcat("\n I heard (from sources) of your journey. Congratulations!"); lprintf("You %s! With several attempts I have yet to endure the", sex?"Bastard":"Bitch"); lprcat(" caves,\nand you, a nobody, make the journey! From this time"); lprcat(" onward, be warned:\nupon our meeting you shall pay the price!\n"); lwclose(); return(1); }
letter4 () { int write_len; sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */ if (lcreat(mail600) < 0) { write_len = write(1,"can't write 600 letter\n",23); return(0); } lprcat("From: [email protected] (Duke of Ularnty)\n"); lprcat("Subject: High Praise\n"); lprcat("\n With a certainty, a hero I declare to be amongst us! A nod of"); lprcat("\nfavour I send to thee. Methinks Count Endelford this day of"); lprcat("\nright breaths fire as of dragon of whom ye are slayer. I"); lprcat("\nyearn to behold his anger and jealously. Should ye choose to"); lprcat("\nunleash some of thy wealth upon those who be unfortunate, I,"); lprcat("\nDuke Mainair, Shall equal thy gift also.\n"); lwclose(); return(1); }
/* * writeboard() Function to write the scoreboard from readboard()'s buffer * * returns -1 if unable to write the scoreboard, returns 0 if all is OK */ static int writeboard(void) { int i; set_score_output(); if (gid != egid) setegid(egid); i = lcreat(scorefile); if (gid != egid) setegid(gid); if (i < 0) { lprcat("Can't write scoreboard\n"); lflush(); return (-1); } lwrite((char *) sco, sizeof(sco)); lwrite((char *) winr, sizeof(winr)); lwclose(); lcreat((char *) 0); return (0); }
letter2 () { int write_len; sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */ if (lcreat(mail600) < 0) { write_len = write(1,"can't write 600 letter\n",23); return(0); } lprcat("From: [email protected] (His Majesty King Wilfred)\n"); lprcat("Subject: a noble deed\n"); lprcat("\n I have heard of your magnificent feat and I, King Wilfred,"); lprcat("\nhereby declare this day to be a national holiday. Furthermore,"); lprcat("\nthree days hence, ye be invited to the castle to receive the"); lprintf("\nhonour of %s of the Realm. Upon thy name shall it be written...", sex?"Knight":"Lady"); lprcat("\nBravery and courage be yours."); lprcat("\nMay you live in happiness for evermore...\n"); lwclose(); return(1); }
letter5 () { int write_len; sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */ if (lcreat(mail600) < 0) { write_len = write(1,"can't write 600 letter\n",23); return(0); } lprcat("From: [email protected] (St. Mary's Children's Home)\n"); lprcat("Subject: these poor children\n"); lprcat("\n News of your great conquest has spread to all of Ularndom."); lprintf("\nMight I have a moment of a great %sman's time? We here at St.", sex?"":"wo"); lprcat("\nMary's Children's Home are very poor and many children are"); lprcat("\nstarving. Disease is widespread and very often fatal without"); lprcat("\ngood food. Could you possibly find it in your heart to help us"); lprcat("\nin our plight? Whatever you could give would help much."); lprcat("\n(your gift is tax-deductible)\n"); lwclose(); return(1); }
/* * Function to create the tax bill for the user */ static int letter1() { /* Prepare path */ sprintf(mail600, "/tmp/#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 600 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" The LRS (Larn Revenue Service)\n"); standout(); lprcat("\nSubject"); standend(); lprcat(" Undeclared Income\n"); lprcat("\n We heard you survived the caverns of Larn. Let be the"); lprcat("\nfirst to congratulate you on your success. It is quite a feat."); lprcat("\nIt must also have been very profitable for you."); lprcat("\n\n The Dungeon Master has informed us that you brought"); lprintf("\n%d gold pieces back with you from your journey. As the", (long)c[GOLD]); lprcat("\ncounty of Larn is in dire need of funds, we have spared no time"); lprintf("\nin preparing your tax bill. You owe %d gold pieces as", (long)c[GOLD] * TAXRATE); lprcat("\nof this notice, and is due within 5 days. Failure to pay will"); lprcat("\nmean penalties. Once again, congratulations, we look forward"); lprcat("\nto your future successful expeditions.\n"); lwclose(); return 1; }
letter6 () { int write_len; sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */ if (lcreat(mail600) < 0) { write_len = write(1,"can't write 600 letter\n",23); return(0); } lprcat("From: [email protected] (National Dianthroritis Society of Ularn)\n"); lprcat("Subject: hope\n"); lprcat("\nCongratulations on your successful expedition. We are sure much"); lprcat("\ncourage and determination was needed on your quest. There are"); lprcat("\nmany though, that could never hope to undertake such a journey"); lprcat("\ndue to an enfeebling disease -- dianthroritis. We at the National"); lprcat("\nDianthroritis Society of Ularn wish to appeal to your philanthropy in"); lprcat("\norder to save many good people -- possibly even yourself or a loved one a few"); lprcat("\nyears from now. Much work needs to be done in researching this"); lprcat("\ndreaded disease and you can help today. Could you please see it"); lprcat("\nin your heart to give generously? Your continued good health"); lprcat("\ncan be your everlasting reward.\n"); lwclose(); return(1); }
void died(int x) { int f, win; char ch; const char *mod; time_t zzz; if (c[LIFEPROT] > 0) { /* if life protection */ switch ((x > 0) ? x : -x) { case 256: case 257: case 262: case 263: case 265: case 266: case 267: case 268: case 269: case 271: case 282: case 284: case 285: case 300: goto invalid; /* can't be saved */ }; --c[LIFEPROT]; c[HP] = 1; --c[CONSTITUTION]; cursors(); lprcat("\nYou feel wiiieeeeerrrrrd all over! "); emit_beep(); lflush(); sleep(4); return; /* only case where died() returns */ } invalid: clearvt100(); lflush(); f = 0; if (ckpflag) unlink(ckpfile);/* remove checkpoint file if used */ if (x < 0) { f++; x = -x; } /* if we are not to display the scores */ if ((x == 300) || (x == 257)) exit(0); /* for quick exit or saved game */ if (x == 263) win = 1; else win = 0; c[GOLD] += c[BANKACCOUNT]; c[BANKACCOUNT] = 0; /* now enter the player at the end of the scoreboard */ newscore(c[GOLD], logname, x, win); diedsub(x); /* print out the score line */ lflush(); set_score_output(); if ((wizard == 0) && (c[GOLD] > 0)) { /* wizards can't score */ #ifndef NOLOG if (gid != egid) setegid(egid); if (lappend(logfile) < 0) { /* append to file */ if (lcreat(logfile) < 0) { /* and can't create new * log file */ lcreat((char *) 0); lprcat("\nCan't open record file: I can't post your score.\n"); sncbr(); resetscroll(); lflush(); exit(0); } if (gid != egid) setegid(egid); chmod(logfile, 0660); if (gid != egid) setegid(gid); } if (gid != egid) setegid(gid); strcpy(logg.who, loginname); logg.score = c[GOLD]; logg.diff = c[HARDGAME]; if (x < 256) { ch = *monster[x].name; if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') mod = "an"; else mod = "a"; snprintf(logg.what, sizeof(logg.what), "killed by %s %s", mod, monster[x].name); } else snprintf(logg.what, sizeof(logg.what), "%s", whydead[x - 256]); logg.cavelev = level; time(&zzz); /* get CPU time -- write out score info */ logg.diedtime = zzz; #ifdef EXTRA times(&cputime);/* get CPU time -- write out score info */ logg.cputime = i = (cputime.tms_utime + cputime.tms_stime) / 60 + c[CPUTIME]; logg.lev = c[LEVEL]; logg.ac = c[AC]; logg.hpmax = c[HPMAX]; logg.hp = c[HP]; logg.elapsedtime = (zzz - initialtime + 59) / 60; logg.usage = (10000 * i) / (zzz - initialtime); logg.bytin = c[BYTESIN]; logg.bytout = c[BYTESOUT]; logg.moves = c[MOVESMADE]; logg.spused = c[SPELLSCAST]; logg.killed = c[MONSTKILLED]; #endif lwrite((char *) &logg, sizeof(struct log_fmt)); lwclose(); #endif /* NOLOG */ /* * now for the scoreboard maintenance -- not for a suspended * game */ if (x != 257) { if (sortboard()) { set_score_output(); scorerror = writeboard(); } } } if ((x == 256) || (x == 257) || (f != 0)) exit(0); if (scorerror == 0) showscores(); /* if we updated the scoreboard */ if (x == 263) mailbill(); exit(0); }