1 /* $NetBSD: main.c,v 1.22 2009/08/12 08:21:41 dholland Exp $ */
4 * Phantasia 3.3.2 -- Interterminal fantasy game
12 * This game is distributed for free as is. It is not guaranteed to work
13 * in every conceivable environment. It is not even guaranteed to work
16 * This game is distributed without notice of copyright, therefore it
17 * may be used in any manner the recipient sees fit. However, the
18 * author assumes no responsibility for maintaining or revising this
19 * game, in its original form, or any derivitives thereof.
21 * The author shall not be responsible for any loss, cost, or damage,
22 * including consequential damage, caused by reliance on this material.
24 * The author makes no warranties, express or implied, including warranties
25 * of merchantability or fitness for a particular purpose or use.
27 * AT&T is in no way connected with this game.
30 #include <sys/types.h>
42 #include "phantdefs.h"
43 #include "phantstruct.h"
44 #include "phantglobs.h"
45 #include "pathnames.h"
51 * The program allocates as much file space as it needs to store characters,
52 * so the possibility exists for the character file to grow without bound.
53 * The file is purged upon normal entry to try to avoid that problem.
54 * A similar problem exists for energy voids. To alleviate the problem here,
55 * the void file is cleared with every new king, and a limit is placed
56 * on the size of the energy void file.
60 * Put one line of text into the file 'motd' for announcements, etc.
64 * The scoreboard file is updated when someone dies, and keeps track
65 * of the highest character to date for that login.
66 * Being purged from the character file does not cause the scoreboard
72 * main.c Main routines for Phantasia
75 static void genchar(int);
76 static void initialstate(void);
77 static void neatstuff(void);
78 static void playinit(void);
79 static void procmain(void);
80 static long recallplayer(void);
81 static long rollnewplayer(void);
82 static void titlelist(void);
84 int main(int, char **);
87 main(int argc
, char **argv
)
89 bool noheader
= FALSE
; /* set if don't want header */
90 bool headeronly
= FALSE
; /* set if only want header */
91 bool examine
= FALSE
; /* set if examine a character */
92 time_t seconds
; /* for time of day */
93 double dtemp
; /* for temporary calculations */
95 initialstate(); /* init globals */
97 /* process arguments */
98 while (--argc
&& (*++argv
)[0] == '-')
100 case 's': /* short */
104 case 'H': /* Header */
108 case 'a': /* all users */
113 case 'p': /* purge old players */
118 case 'S': /* set 'Wizard' */
122 case 'x': /* examine */
126 case 'm': /* monsters */
131 case 'b': /* scoreboard */
137 if (!isatty(0)) /* don't let non-tty's play */
141 playinit(); /* set up to catch signals, init curses */
150 purgeoldplayers(); /* clean up old characters */
157 /* get the player structure filled */
161 mvaddstr(22, 17, "Do you have a character to run [Q = Quit] ? ");
163 switch (getanswer("NYQ", FALSE
)) {
165 Fileloc
= recallplayer();
173 Fileloc
= rollnewplayer();
178 while (Fileloc
< 0L);
180 if (Player
.p_level
> 5.0)
181 /* low level players have long timeout */
184 /* update some important player statistics */
185 strlcpy(Player
.p_login
, Login
, sizeof(Player
.p_login
));
187 Player
.p_lastused
= localtime(&seconds
)->tm_yday
;
188 Player
.p_status
= S_PLAYING
;
189 writerecord(&Player
, Fileloc
);
191 Statptr
= &Stattable
[Player
.p_type
]; /* initialize pointer */
193 /* catch interrupts */
195 sigset(SIGINT
, interrupt
);
198 signal(SIGINT
, interrupt
);
201 signal(SIGINT
, interrupt
);
204 signal(SIGINT
, interrupt
);
207 altercoordinates(Player
.p_x
, Player
.p_y
, A_FORCED
); /* set some flags */
212 /* loop forever, processing input */
215 adjuststats(); /* cleanup stats */
217 if (Throne
&& Player
.p_crowns
== 0 && Player
.p_specialtype
!= SC_KING
)
218 /* not allowed on throne -- move */
220 mvaddstr(5, 0, "You're not allowed in the Lord's Chamber without a crown.\n");
221 altercoordinates(0.0, 0.0, A_NEAR
);
223 checktampered();/* check for energy voids, etc. */
225 if (Player
.p_status
!= S_CLOAKED
227 && (dtemp
= fabs(Player
.p_x
)) == fabs(Player
.p_y
)
232 dtemp
= sqrt(dtemp
/ 100.0);
233 if (floor(dtemp
) == dtemp
)
234 /* |x| / 100 == n*n; at a trading post */
240 checkbattle(); /* check for player to player battle */
241 neatstuff(); /* gurus, medics, etc. */
243 if (Player
.p_status
== S_CLOAKED
) {
244 /* costs 3 mana per turn to be cloaked */
245 if (Player
.p_mana
> 3.0)
246 Player
.p_mana
-= 3.0;
248 /* ran out of mana, uncloak */
250 Player
.p_status
= S_PLAYING
;
255 if (Player
.p_status
!= S_PLAYING
&& Player
.p_status
!= S_CLOAKED
)
256 /* change status back to S_PLAYING */
258 Player
.p_status
= S_PLAYING
;
262 /* update file only if important stuff has changed */
264 writerecord(&Player
, Fileloc
);
268 readmessage(); /* read message, if any */
270 displaystats(); /* print statistics */
275 /* maybe make king, print prompt, etc. */
278 /* print status line */
279 addstr("1:Move 2:Players 3:Talk 4:Stats 5:Quit ");
280 if (Player
.p_level
>= MEL_CLOAK
&& Player
.p_magiclvl
>= ML_CLOAK
)
282 if (Player
.p_level
>= MEL_TELEPORT
&& Player
.p_magiclvl
>= ML_TELEPORT
)
283 addstr("7:Teleport ");
284 if (Player
.p_specialtype
>= SC_COUNCIL
|| Wizard
)
285 addstr("8:Intervene ");
287 procmain(); /* process input */
307 /* setup login name */
308 if ((Login
= getlogin()) == NULL
) {
309 pw
= getpwuid(getuid());
311 errx(1, "Who are you?");
316 /* open some files */
317 if ((Playersfp
= fopen(_PATH_PEOPLE
, "r+")) == NULL
)
320 if (fileno(Playersfp
) < 3)
323 if ((Monstfp
= fopen(_PATH_MONST
, "r+")) == NULL
)
327 if ((Messagefp
= fopen(_PATH_MESS
, "r")) == NULL
)
331 if ((Energyvoidfp
= fopen(_PATH_VOID
, "r+")) == NULL
)
333 if (fstat(fileno(Energyvoidfp
), &sb
) == -1)
335 if (sb
.st_size
== 0) {
336 /* initialize grail to new location */
337 Enrgyvoid
.ev_active
= TRUE
;
338 Enrgyvoid
.ev_x
= ROLL(-1.0e6
, 2.0e6
);
339 Enrgyvoid
.ev_y
= ROLL(-1.0e6
, 2.0e6
);
340 writevoid(&Enrgyvoid
, 0L);
345 srandom((unsigned) time(NULL
)); /* prime random numbers */
351 int chartype
; /* character type */
354 initplayer(&Player
); /* initialize player structure */
357 mvaddstr(4, 21, "Which type of character do you want:");
359 "1:Magic User 2:Fighter 3:Elf 4:Dwarf 5:Halfling 6:Experimento ");
361 addstr("7:Super ? ");
362 chartype
= getanswer("1234567", FALSE
);
365 chartype
= getanswer("123456", FALSE
);
369 genchar(chartype
); /* roll up a character */
371 /* print out results */
373 "Strength : %2.0f Quickness: %2.0f Mana : %2.0f\n",
374 Player
.p_strength
, Player
.p_quickness
, Player
.p_mana
);
376 "Energy Level: %2.0f Brains : %2.0f Magic Level: %2.0f\n",
377 Player
.p_energy
, Player
.p_brains
, Player
.p_magiclvl
);
379 if (Player
.p_type
== C_EXPER
|| Player
.p_type
== C_SUPER
)
382 mvaddstr(14, 14, "Type '1' to keep >");
383 ch
= getanswer(" ", TRUE
);
387 if (Player
.p_type
== C_EXPER
|| Player
.p_type
== C_SUPER
)
388 /* get coordinates for experimento */
390 mvaddstr(16, 0, "Enter the X Y coordinates of your experimento ? ");
391 getstring(Databuf
, SZ_DATABUF
);
392 sscanf(Databuf
, "%lf %lf", &Player
.p_x
, &Player
.p_y
);
394 if (fabs(Player
.p_x
) > D_EXPER
|| fabs(Player
.p_y
) > D_EXPER
)
395 mvaddstr(17, 0, "Invalid coordinates. Try again.\n");
401 /* name the new character */
404 "Give your character a name [up to %d characters] ? ", SZ_NAME
- 1);
405 getstring(Player
.p_name
, SZ_NAME
);
406 truncstring(Player
.p_name
); /* remove trailing blanks */
408 if (Player
.p_name
[0] == '\0')
410 mvaddstr(19, 0, "Invalid name.");
412 if (findname(Player
.p_name
, &Other
) >= 0L)
413 /* cannot have duplicate names */
414 mvaddstr(19, 0, "Name already in use.");
416 /* name is acceptable */
419 addstr(" Pick another.\n");
422 /* get a password for character */
426 mvaddstr(20, 0, "Give your character a password [up to 8 characters] ? ");
427 getstring(Player
.p_password
, SZ_PASSWORD
);
428 mvaddstr(21, 0, "Enter again to verify: ");
429 getstring(Databuf
, SZ_PASSWORD
);
431 while (strcmp(Player
.p_password
, Databuf
) != 0);
435 return (allocrecord());
442 double x
; /* desired new x coordinate */
443 double y
; /* desired new y coordinate */
444 double temp
; /* for temporary calculations */
445 FILE *fp
; /* for opening files */
446 int loop
; /* a loop counter */
447 bool hasmoved
= FALSE
; /* set if player has moved */
450 mvaddstr(4, 0, "\n\n"); /* clear status area */
453 clrtobot(); /* clear data on bottom area of screen */
455 if (Player
.p_specialtype
== SC_VALAR
&& (ch
== '1' || ch
== '7'))
456 /* valar cannot move */
460 case 'K': /* move up/north */
463 y
= Player
.p_y
+ MAXMOVE();
467 case 'J': /* move down/south */
470 y
= Player
.p_y
- MAXMOVE();
474 case 'L': /* move right/east */
476 x
= Player
.p_x
+ MAXMOVE();
481 case 'H': /* move left/west */
483 x
= Player
.p_x
- MAXMOVE();
489 Player
.p_energy
+= (Player
.p_maxenergy
+ Player
.p_shield
) / 15.0
490 + Player
.p_level
/ 3.0 + 2.0;
492 MIN(Player
.p_energy
, Player
.p_maxenergy
+ Player
.p_shield
);
494 if (Player
.p_status
!= S_CLOAKED
)
495 /* cannot find mana if cloaked */
497 Player
.p_mana
+= (Circle
+ Player
.p_level
) / 4.0;
499 if (drandom() < 0.2 && Player
.p_status
== S_PLAYING
&& !Throne
)
500 /* wandering monster */
505 case 'X': /* change/examine a character */
510 for (loop
= 3; loop
; --loop
) {
511 mvaddstr(4, 0, "X Y Coordinates ? ");
512 getstring(Databuf
, SZ_DATABUF
);
514 if (sscanf(Databuf
, "%lf %lf", &x
, &y
) != 2)
515 mvaddstr(5, 0, "Try again\n");
517 if (distance(Player
.p_x
, x
, Player
.p_y
, y
) > MAXMOVE())
526 case '2': /* players */
530 case '3': /* message */
531 mvaddstr(4, 0, "Message ? ");
532 getstring(Databuf
, SZ_DATABUF
);
533 /* we open the file for writing to erase any data which is
535 fp
= fopen(_PATH_MESS
, "w");
536 if (Databuf
[0] != '\0')
537 fprintf(fp
, "%s: %s", Player
.p_name
, Databuf
);
541 case '4': /* stats */
545 case '5': /* good-bye */
549 case '6': /* cloak */
550 if (Player
.p_level
< MEL_CLOAK
|| Player
.p_magiclvl
< ML_CLOAK
)
553 if (Player
.p_status
== S_CLOAKED
)
554 Player
.p_status
= S_PLAYING
;
556 if (Player
.p_mana
< MM_CLOAK
)
557 mvaddstr(5, 0, "No mana left.\n");
560 Player
.p_mana
-= MM_CLOAK
;
561 Player
.p_status
= S_CLOAKED
;
565 case '7': /* teleport */
567 * conditions for teleport
568 * - 20 per (level plus magic level)
569 * - OR council of the wise or valar or ex-valar
570 * - OR transport from throne
571 * transports from throne cost no mana
573 if (Player
.p_level
< MEL_TELEPORT
|| Player
.p_magiclvl
< ML_TELEPORT
)
576 for (loop
= 3; loop
; --loop
) {
577 mvaddstr(4, 0, "X Y Coordinates ? ");
578 getstring(Databuf
, SZ_DATABUF
);
580 if (sscanf(Databuf
, "%lf %lf", &x
, &y
) == 2) {
581 temp
= distance(Player
.p_x
, x
, Player
.p_y
, y
);
583 /* can transport anywhere from throne */
584 && Player
.p_specialtype
<= SC_COUNCIL
585 /* council, valar can transport
587 && temp
> (Player
.p_level
+ Player
.p_magiclvl
) * 20.0)
588 /* can only move 20 per exp.
589 * level + mag. level */
592 temp
= (temp
/ 75.0 + 1.0) * 20.0; /* mana used */
594 if (!Throne
&& temp
> Player
.p_mana
)
595 mvaddstr(5, 0, "Not enough power for that distance.\n");
598 Player
.p_mana
-= temp
;
608 case '9': /* monster */
610 /* no monsters while on throne */
611 mvaddstr(5, 0, "No monsters in the chamber!\n");
613 if (Player
.p_specialtype
!= SC_VALAR
)
614 /* the valar cannot call monsters */
616 Player
.p_sin
+= 1e-6;
621 case '0': /* decree */
622 if (Wizard
|| (Player
.p_specialtype
== SC_KING
&& Throne
))
623 /* kings must be on throne to decree */
629 case '8': /* intervention */
630 if (Wizard
|| Player
.p_specialtype
>= SC_COUNCIL
)
638 /* player has moved -- alter coordinates, and do random
641 altercoordinates(x
, y
, A_SPECIFIC
);
643 if (drandom() < 0.2 && Player
.p_status
== S_PLAYING
&& !Throne
)
651 FILE *fp
; /* used for opening various files */
652 bool councilfound
= FALSE
; /* set if we find a member of the
654 bool kingfound
= FALSE
; /* set if we find a king */
655 double hiexp
, nxtexp
; /* used for finding the two highest players */
656 double hilvl
, nxtlvl
; /* used for finding the two highest players */
657 char hiname
[21], nxtname
[21]; /* used for finding the two
662 "W e l c o m e t o P h a n t a s i a (vers. 3.3.2)!");
664 /* print message of the day */
665 if ((fp
= fopen(_PATH_MOTD
, "r")) != NULL
666 && fgets(Databuf
, SZ_DATABUF
, fp
) != NULL
) {
667 mvaddstr(2, 40 - strlen(Databuf
) / 2, Databuf
);
670 /* search for king */
671 fseek(Playersfp
, 0L, SEEK_SET
);
672 while (fread((char *) &Other
, SZ_PLAYERSTRUCT
, 1, Playersfp
) == 1)
673 if (Other
.p_specialtype
== SC_KING
&&
674 Other
.p_status
!= S_NOTUSED
)
677 snprintf(Databuf
, SZ_DATABUF
,
678 "The present ruler is %s Level:%.0f",
679 Other
.p_name
, Other
.p_level
);
680 mvaddstr(4, 40 - strlen(Databuf
) / 2, Databuf
);
685 mvaddstr(4, 24, "There is no ruler at this time.");
687 /* search for valar */
688 fseek(Playersfp
, 0L, SEEK_SET
);
689 while (fread((char *) &Other
, SZ_PLAYERSTRUCT
, 1, Playersfp
) == 1)
690 if (Other
.p_specialtype
== SC_VALAR
&& Other
.p_status
!= S_NOTUSED
)
691 /* found the valar */
693 snprintf(Databuf
, SZ_DATABUF
,
694 "The Valar is %s Login: %s",
695 Other
.p_name
, Other
.p_login
);
696 mvaddstr(6, 40 - strlen(Databuf
) / 2, Databuf
);
699 /* search for council of the wise */
700 fseek(Playersfp
, 0L, SEEK_SET
);
702 while (fread((char *) &Other
, SZ_PLAYERSTRUCT
, 1, Playersfp
) == 1)
703 if (Other
.p_specialtype
== SC_COUNCIL
&& Other
.p_status
!= S_NOTUSED
)
704 /* found a member of the council */
707 mvaddstr(8, 30, "Council of the Wise:");
710 /* This assumes a finite (<=5) number of C.O.W.: */
711 snprintf(Databuf
, SZ_DATABUF
,
712 "%s Login: %s", Other
.p_name
, Other
.p_login
);
713 mvaddstr(Lines
++, 40 - strlen(Databuf
) / 2, Databuf
);
715 /* search for the two highest players */
716 nxtname
[0] = hiname
[0] = '\0';
720 fseek(Playersfp
, 0L, SEEK_SET
);
721 while (fread((char *) &Other
, SZ_PLAYERSTRUCT
, 1, Playersfp
) == 1)
722 if (Other
.p_experience
> hiexp
&& Other
.p_specialtype
<= SC_KING
&& Other
.p_status
!= S_NOTUSED
)
723 /* highest found so far */
726 hiexp
= Other
.p_experience
;
728 hilvl
= Other
.p_level
;
729 strcpy(nxtname
, hiname
);
730 strcpy(hiname
, Other
.p_name
);
732 if (Other
.p_experience
> nxtexp
733 && Other
.p_specialtype
<= SC_KING
734 && Other
.p_status
!= S_NOTUSED
)
735 /* next highest found so far */
737 nxtexp
= Other
.p_experience
;
738 nxtlvl
= Other
.p_level
;
739 strcpy(nxtname
, Other
.p_name
);
741 mvaddstr(15, 28, "Highest characters are:");
742 snprintf(Databuf
, SZ_DATABUF
,
743 "%s Level:%.0f and %s Level:%.0f",
744 hiname
, hilvl
, nxtname
, nxtlvl
);
745 mvaddstr(17, 40 - strlen(Databuf
) / 2, Databuf
);
747 /* print last to die */
748 if ((fp
= fopen(_PATH_LASTDEAD
, "r")) != NULL
749 && fgets(Databuf
, SZ_DATABUF
, fp
) != NULL
) {
750 mvaddstr(19, 25, "The last character to die was:");
751 mvaddstr(20, 40 - strlen(Databuf
) / 2, Databuf
);
761 long loc
= 0L; /* location in player file */
762 int loop
; /* loop counter */
766 mvprintw(10, 0, "What was your character's name ? ");
767 getstring(Databuf
, SZ_NAME
);
768 truncstring(Databuf
);
770 if ((loc
= findname(Databuf
, &Player
)) >= 0L)
771 /* found character */
775 for (loop
= 0; loop
< 2; ++loop
) {
776 /* prompt for password */
777 mvaddstr(11, 0, "Password ? ");
778 getstring(Databuf
, SZ_PASSWORD
);
779 if (strcmp(Databuf
, Player
.p_password
) == 0)
784 if (Player
.p_status
!= S_OFF
)
785 /* player did not exit normally last
789 addstr("Your character did not exit normally last time.\n");
790 addstr("If you think you have good cause to have your character saved,\n");
791 printw("you may quit and mail your reason to 'root'.\n");
792 addstr("Otherwise, continuing spells certain death.\n");
793 addstr("Do you want to quit ? ");
794 ch
= getanswer("YN", FALSE
);
796 Player
.p_status
= S_HUNGUP
;
797 writerecord(&Player
, loc
);
806 mvaddstr(12, 0, "No good.\n");
811 mvaddstr(11, 0, "Not found.\n");
820 double temp
; /* for temporary calculations */
823 switch ((int) ROLL(0.0, 100.0)) {
826 if (Player
.p_poison
> 0.0) {
827 mvaddstr(4, 0, "You've found a medic! How much will you offer to be cured ? ");
828 temp
= floor(infloat());
829 if (temp
< 0.0 || temp
> Player
.p_gold
)
830 /* negative gold, or more than available */
832 mvaddstr(6, 0, "He was not amused, and made you worse.\n");
833 Player
.p_poison
+= 1.0;
835 if (drandom() / 2.0 > (temp
+ 1.0) / MAX(Player
.p_gold
, 1))
836 /* medic wants 1/2 of available gold */
837 mvaddstr(5, 0, "Sorry, he wasn't interested.\n");
839 mvaddstr(5, 0, "He accepted.");
840 Player
.p_poison
= MAX(0.0, Player
.p_poison
- 1.0);
841 Player
.p_gold
-= temp
;
847 mvaddstr(4, 0, "You've been caught raping and pillaging!\n");
848 Player
.p_experience
+= 4000.0;
853 temp
= ROLL(10.0, 75.0);
854 mvprintw(4, 0, "You've found %.0f gold pieces, want them ? ", temp
);
855 ch
= getanswer("NY", FALSE
);
858 collecttaxes(temp
, 0.0);
862 if (Player
.p_sin
> 1.0) {
863 mvaddstr(4, 0, "You've found a Holy Orb!\n");
864 Player
.p_sin
-= 0.25;
869 if (Player
.p_poison
< 1.0) {
870 mvaddstr(4, 0, "You've been hit with a plague!\n");
871 Player
.p_poison
+= 1.0;
876 mvaddstr(4, 0, "You've found some holy water.\n");
877 ++Player
.p_holywater
;
881 mvaddstr(4, 0, "You've met a Guru. . .");
882 if (drandom() * Player
.p_sin
> 1.0)
883 addstr("You disgusted him with your sins!\n");
885 if (Player
.p_poison
> 0.0) {
886 addstr("He looked kindly upon you, and cured you.\n");
887 Player
.p_poison
= 0.0;
889 addstr("He rewarded you for your virtue.\n");
890 Player
.p_mana
+= 50.0;
891 Player
.p_shield
+= 2.0;
896 mvaddstr(4, 0, "You've found an amulet.\n");
901 if (Player
.p_blindness
) {
902 mvaddstr(4, 0, "You've regained your sight!\n");
903 Player
.p_blindness
= FALSE
;
907 default: /* deal with poison */
908 if (Player
.p_poison
> 0.0) {
909 temp
= Player
.p_poison
* Statptr
->c_weakness
910 * Player
.p_maxenergy
/ 600.0;
911 if (Player
.p_energy
> Player
.p_maxenergy
/ 10.0
912 && temp
+ 5.0 < Player
.p_energy
)
913 Player
.p_energy
-= temp
;
922 int subscript
; /* used for subscripting into Stattable */
923 const struct charstats
*statptr
; /* for pointing into Stattable */
925 subscript
= type
- '1';
927 if (subscript
< C_MAGIC
|| subscript
> C_EXPER
)
928 if (subscript
!= C_SUPER
|| !Wizard
)
929 /* fighter is default */
930 subscript
= C_FIGHTER
;
932 statptr
= &Stattable
[subscript
];
935 ROLL(statptr
->c_quickness
.base
, statptr
->c_quickness
.interval
);
937 ROLL(statptr
->c_strength
.base
, statptr
->c_strength
.interval
);
939 ROLL(statptr
->c_mana
.base
, statptr
->c_mana
.interval
);
942 ROLL(statptr
->c_energy
.base
, statptr
->c_energy
.interval
);
944 ROLL(statptr
->c_brains
.base
, statptr
->c_brains
.interval
);
946 ROLL(statptr
->c_magiclvl
.base
, statptr
->c_magiclvl
.interval
);
948 Player
.p_type
= subscript
;
950 if (Player
.p_type
== C_HALFLING
)
951 /* give halfling some experience */
952 Player
.p_experience
= ROLL(600.0, 200.0);
958 /* catch/ingnore signals */
968 sigset(SIGHUP
, ill_sig
);
969 sigset(SIGTRAP
, ill_sig
);
970 sigset(SIGIOT
, ill_sig
);
971 sigset(SIGEMT
, ill_sig
);
972 sigset(SIGFPE
, ill_sig
);
973 sigset(SIGBUS
, ill_sig
);
974 sigset(SIGSEGV
, ill_sig
);
975 sigset(SIGSYS
, ill_sig
);
976 sigset(SIGPIPE
, ill_sig
);
979 signal(SIGQUIT
, ill_sig
);
980 signal(SIGALRM
, SIG_IGN
);
981 signal(SIGTERM
, SIG_IGN
);
982 signal(SIGTSTP
, SIG_IGN
);
983 signal(SIGTTIN
, SIG_IGN
);
984 signal(SIGTTOU
, SIG_IGN
);
985 signal(SIGINT
, ill_sig
);
986 signal(SIGHUP
, SIG_DFL
);
987 signal(SIGTRAP
, ill_sig
);
988 signal(SIGIOT
, ill_sig
);
989 signal(SIGEMT
, ill_sig
);
990 signal(SIGFPE
, ill_sig
);
991 signal(SIGBUS
, ill_sig
);
992 signal(SIGSEGV
, ill_sig
);
993 signal(SIGSYS
, ill_sig
);
994 signal(SIGPIPE
, ill_sig
);
997 signal(SIGINT
, SIG_IGN
);
998 signal(SIGQUIT
, SIG_IGN
);
999 signal(SIGTERM
, SIG_IGN
);
1000 signal(SIGALRM
, SIG_IGN
);
1001 signal(SIGHUP
, ill_sig
);
1002 signal(SIGTRAP
, ill_sig
);
1003 signal(SIGIOT
, ill_sig
);
1004 signal(SIGEMT
, ill_sig
);
1005 signal(SIGFPE
, ill_sig
);
1006 signal(SIGBUS
, ill_sig
);
1007 signal(SIGSEGV
, ill_sig
);
1008 signal(SIGSYS
, ill_sig
);
1009 signal(SIGPIPE
, ill_sig
);
1012 signal(SIGINT
, SIG_IGN
);
1013 signal(SIGQUIT
, SIG_IGN
);
1014 signal(SIGTERM
, SIG_IGN
);
1015 signal(SIGALRM
, SIG_IGN
);
1016 signal(SIGHUP
, ill_sig
);
1017 signal(SIGTRAP
, ill_sig
);
1018 signal(SIGIOT
, ill_sig
);
1019 signal(SIGEMT
, ill_sig
);
1020 signal(SIGFPE
, ill_sig
);
1021 signal(SIGBUS
, ill_sig
);
1022 signal(SIGSEGV
, ill_sig
);
1023 signal(SIGSYS
, ill_sig
);
1024 signal(SIGPIPE
, ill_sig
);
1027 if (!initscr()) { /* turn on curses */
1028 fprintf(stderr
, "couldn't initialize screen\n");
1031 noecho(); /* do not echo input */
1032 cbreak(); /* do not process erase, kill */
1035 Windows
= TRUE
; /* mark the state */
1054 fclose(Energyvoidfp
);