home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / EVENTS / LONEW11.ZIP / LONEWOLF.C < prev    next >
Text File  |  1989-10-25  |  33KB  |  1,477 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #include <dir.h>
  8. #include <dos.h>
  9.  
  10.  
  11. /* >>>COMMENTED SKELETON.C<<< by WAYNE BELL with comments by DOUG FIELDS */
  12.  
  13. /* A commented version of SKELETON.C. All comments except global variable discriptions
  14.    are by Doug Fields, voice tel # 203-661-2976 (in CT). This program is copyright (I think it is at least)
  15.    by Wayne Bell, the programmer of WWIV. All code is his in FULL, this is
  16.    just a revision making it understandable to the novice. NOTE: This is for version 4.04
  17.    and other versions which pass the comport and bps/baud rate. Also NOTE that
  18.    this uses UNIX style file I/O instead of the ANSI proposed standard. If
  19.    you have any questions/comments feel free to call me (at reasonable hrs.). */
  20.  
  21.  
  22. int    usernum,        /* user number for the user */
  23.        age,        /* age of the user */
  24.        screenchars,    /* chars/line user has specified */
  25.        screenlines,    /* lines/screen user has specified */
  26.        sl,        /* sec lev for user (0-255) */
  27.        so,        /* non-zero if user is sysop (sl=255) */
  28.        cs,        /* non-zero if user is co-sysop */
  29.        okansi,        /* non-zero if user can support ANSI */
  30.        incom,        /* non-zero if user is calling remotely */
  31.        comport;        /* com port user is on */
  32. char   name[81],    /* name/alias of user */
  33.        realname[81],    /* real name of user */
  34.        callsign[10],    /* amateur radio callsign of user */
  35.        sex,        /* sex of user, M or F */
  36.        laston[81],    /* date user was last on */
  37.        gfiles[81],    /* directory for text files, ends in \ */
  38.        data[81],    /* directory for non-text files, ends in \ */
  39.        sysoplog[81],    /* full path & filename for sysop log */
  40.        curspeed[81];    /* speed user is on at, "KB" if local */
  41. double gold,        /* gold user has */
  42.        timeallowed;    /* number of seconds before user logged off */
  43.  
  44.  
  45. int read_in_data(char *fn)
  46.  
  47. /* This function will take the filename passed to it and open it as if it
  48.    were a CHAIN.TXT file and take all information out of it and place it into
  49.    the global variables defined above. If it fails to open the file, it will
  50.    return -1. */
  51.  
  52. {
  53.   char buf[1024];  /* This is where the file will be put for fast access. */
  54.   char *ptr[30];   /* This will hold pointers to parts of the buf array,
  55.               acting as an index. */
  56.   int i,f,len,i1;  /* i, i1 = loop control variables;
  57.               len = number of bytes read from file;
  58.               f = file descriptor number for the filename. */
  59.   float fl;        /* This holds a temporary value of the user's gold. */
  60.                    /* fn = the filename of the CHAIN.TXT file. */
  61.  
  62.   f=open(fn,O_RDONLY | O_BINARY);  /* Open the file for input as a binary file,
  63.                       i.e. without character translations. */
  64.   if (f<0) {                       /* If the file descriptor (f) is less than
  65.                       0 (i.e. it is -1) then abort the
  66.                       function and return error (-1). */
  67.     return(-1);
  68.   }
  69.   i1=1;                            /* Initialize i1. */
  70.   ptr[0]=buf;                      /* Point the first index to the first character
  71.                       of the buf array. */
  72.   len=read(f,(void *)buf,1024);    /* Read in from the file f into buf up to
  73.                       1024 characters (until the EOF is reached)
  74.                       and return the actual number of characters
  75.                       read in len. */
  76.   close(f);                        /* We're finished with the file so put it
  77.                       away. */
  78.   for (i=0; i<len; i++)            /* This for loop goes through the buf array
  79.                       (which now contains the contents of the
  80.                       chain info file) and assigns indices to
  81.                       the ptr array of pointers. It causes all
  82.                       returns to be mapped into null characters
  83.                       (ASCII 0) for use as strings, and skips
  84.                       over the following LF character. In this
  85.                       way, ptr will end up pointing to a bunch
  86.                       of character strings. */
  87.     if (buf[i]==13) {
  88.       buf[i]=0;
  89.       ptr[i1++]=&buf[i+2];
  90.     }
  91.   while (*ptr[6]==32)              /* Remove leading spaces for the float
  92.                       values by incrementing the pointer
  93.                       by one character. */
  94.     ++(ptr[6]);
  95.   while (*ptr[15]==32)
  96.     ++(ptr[15]);
  97.   usernum=atoi(ptr[0]);            /* From here on it is straight translation
  98.                       from the ptr index array into the global
  99.                       variables. */
  100.                    /* Get the user number from index 0. */
  101.   strcpy(name,ptr[1]);           /* Get the name, real name, and callsign. */
  102.   strcpy(realname,ptr[2]);
  103.   strcpy(callsign,ptr[3]);
  104.   age=atoi(ptr[4]);                /* Get the user's age. */
  105.   sex=*ptr[5];               /* Get the user's sex. */
  106.   sscanf(ptr[6],"%f",&fl);         /* These two lines read in the user's gold
  107.                       and typecast it into a double float. */
  108.   gold=(double)fl;
  109.   strcpy(laston,ptr[7]);           /* Get his date of last being on. */
  110.   screenchars=atoi(ptr[8]);        /* Get the size of his screen. */
  111.   screenlines=atoi(ptr[9]);
  112.   sl=atoi(ptr[10]);                /* Get his seclev. */
  113.   so=atoi(ptr[11]);                /* Is he a sysop? (nonzero if true) */
  114.   cs=atoi(ptr[12]);                /* How about a cosysop? */
  115.   okansi=atoi(ptr[13]);            /* Does he use ANSI graphics? */
  116.   incom=atoi(ptr[14]);             /* Is he calling remotely (1) or not? */
  117.   sscanf(ptr[15],"%f",&fl);        /* These two lines read in the number of
  118.                       seconds left to the user and typecast
  119.                       the value into a double float. */
  120.   timeallowed=(double)fl;
  121.   strcpy(gfiles,ptr[16]);          /* What is the gfiles dir? */
  122.   strcpy(data,ptr[17]);            /* What is the data dir? */
  123.   strcpy(sysoplog,gfiles);         /* These two lines get the full pathname
  124.                       for the sysoplog file. */
  125.   strcat(sysoplog,ptr[18]);
  126.   strcpy(curspeed,ptr[19]);        /* A string containing the user's
  127.                       bps/baud rate or KB if local. */
  128.   comport=atoi(ptr[20]);           /* The user's comport if remote. */
  129.   return(0);                       /* Return and give a 'we read it in fine'
  130.                       message. */
  131. }
  132.  
  133. char directory[81];
  134. struct date date;
  135.  
  136. void main(int argc, char *argv[])
  137. {
  138.     FILE *fptr;
  139.     char path[81];
  140.  
  141.  
  142.   argc=argc;                       /* God knows what this line is for. */
  143.   if (read_in_data(argv[1])==-1) { /* Try to read in the parameter file
  144.                       and if it returns the -1 error message,
  145.                       quit the program with an error message. */
  146.     printf("\nData file not found\n\n");
  147.     abort();
  148.     }
  149.  
  150.  
  151. getdate(&date);
  152.  
  153. getcwd(directory,80);
  154.  
  155. if((fptr=fopen("path.lw","r"))==NULL)
  156.         {
  157.             printf("There is a problem");
  158.             exit(0);
  159.         }
  160.     fgets(path,80,fptr);
  161.     fclose(fptr);
  162.     chdir(path);
  163.  
  164. welcome();
  165. }
  166.  
  167. #include "color.h"
  168.  
  169.  
  170. struct PLAYER
  171.     {
  172.             char name[81];
  173.     int number,
  174.             combat_skill,
  175.             endurance,
  176.             origendur,
  177.             skill[6],
  178.             weoponskill,
  179.             weopons[3],
  180.             food,
  181.             money,
  182.             moves,
  183.             day,
  184.             location,
  185.             special[101];
  186.             long score;
  187.     }player,player1;
  188.  
  189.     struct COUNTER
  190.     {
  191.      int count;
  192.     }counter;
  193.  
  194.     struct ROOMCH
  195.     {
  196.      int roomnum;
  197.      int roomtype;
  198.      int choice[5];
  199.      int dis[5];
  200.      int randhi[5];
  201.      int randlow[5];
  202.      int combat[5];
  203.      int endurance[5];
  204.      int comadder;          /*added to you combat*/
  205.      int endadder;                        /*added to your endurnce for this fight*/
  206.      int weaponin;
  207.      int specialin;
  208.      int specialuse;
  209.      int specialuse_adder;
  210.      int moneyin;
  211.      int moneyuse;
  212.      int foodin;
  213.      int fooduse;
  214.     }roomch;
  215.  
  216. struct SCORE
  217. {
  218.     char name[81];
  219.     long score;
  220. }scores[10];
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227. char *disciplines[11]={"none","Camouflage","Hunting","Sixth Sense","Tracking",
  228. "Healing","Weaponskill","Mindshield","Mindblast","Animal Kinship","Mind over Matter"};
  229.  
  230. char *weopons[13]={"Dagger","Spear","Mace","Short Sword","WarHammer","Sword",
  231. "Axe","Sword","Quarterstaff","Broadsword","none","none","none"};
  232.  
  233. char *spec[20]={"none","Helmet","Chainmail","Vordak Gem","healing potion",
  234. "Golden Key","Silver Key","20 Gems","Potion of Strength","Torch","Scrolls",
  235. "Message on animal skin","perfumed soap","Star on a Chain"};
  236.  
  237. int current=1,store,spot,stop;
  238.  
  239. welcome()
  240. {
  241.     FILE *fptr,*fptr1;
  242.     char *file2={"instruct.sw"},ch;
  243.     int x,y,chec;
  244.     long offset;
  245.  
  246.     printf(CLEAR);
  247.     printf("\n\n\n");
  248.     printf("The Adventures of Lone Wolf\n\n");
  249.     printf("Version 1.1\n");
  250.     printf("Programmed in \"C\" by Packer Fan 1@8252 and Krago of the Mountains 9@8252\n\n");
  251.     printf("on The AFTERMATH BBS, Terre Haute, Indiana\n\n");
  252.     printf("Based on the book of the same name\n");
  253.     printf(" By Joe Dever and Gary Chalk\n");
  254.     printf("c 1984, Pacer Books, New York\n");
  255.  
  256.     printf("Press Enter to continue");
  257.     check();
  258.     getche();
  259.     printf(CLEAR);
  260.     printf("\n\nDo you need instructions??");
  261.     check();
  262.     ch=getche();
  263.     if(ch=='y' || ch=='Y') type(&file2);
  264.     printf(CLEAR);
  265.     printf("Would you like to see the High Score list?");
  266.     ch=getche();
  267.     if(ch=='y' || ch=='Y') Scores();
  268.  
  269.     printf("Searching for previous games\n");
  270.     if((fptr1=fopen("counters.sw","rb")) == NULL)
  271.             {
  272.                 printf(" Can't open counter file\n");
  273.                 exit(0);
  274.             }
  275.             else
  276.             {
  277.                 fread(&counter,sizeof(counter),1,fptr1);
  278.                 store=counter.count;
  279.             }
  280.  
  281.     if((fptr=fopen("players.sw","rb")) == NULL)
  282.     {
  283.         printf(" Can't open player file\n");
  284.         exit(0);
  285.     }
  286.     offset=0;
  287.     chec=counter.count-1;
  288.     for(x=0;x<=chec;x++)
  289.     {
  290.         if(x!=0)
  291.         {
  292.             offset=x*sizeof(player);
  293.             fseek(fptr,offset,0);
  294.         }
  295.         fread(&player,sizeof(player),1,fptr);
  296.         if(strcmp(player.name,name)==0)
  297.         {
  298.          spot=offset;
  299.          fclose(fptr);
  300.          game();
  301.         }
  302.     }
  303.     fclose(fptr);
  304.  
  305.     printf("\nWould you like to play now?");
  306.     check();
  307.     ch=getche();
  308.     if(ch=='y' || ch=='Y')
  309.      {
  310.      player.number=counter.count;
  311.          counter.count=counter.count+1;
  312.          store=counter.count;
  313.          current=0;
  314.          player.score=0;
  315.          strcpy(player.name,name);
  316.          player.weopons[0]=0;
  317.          player.location=1;
  318.          for(y=0;y<=5;y++)
  319.          {
  320.             player.skill[y]=0;
  321.          }
  322.          player.food=0;
  323.          for(y=0;y<=100;y++)
  324.          {
  325.             player.special[y]=0;
  326.          }
  327.          init();
  328.         }
  329.         else
  330.         {
  331.         chdir(directory);
  332.         exit(0);
  333.         }
  334. }
  335.  
  336.  
  337.  
  338. init()
  339. {
  340.     char choice[4];
  341.     int mytime;
  342.  
  343.     player.weopons[2]=12;
  344.     player.day=date.da_day;
  345.     player.moves=30;
  346.     randomize();
  347.     printf(CLEAR);
  348.   printf("Your Location is now %d\n",player.location);
  349.     player.combat_skill=random(9)+10;
  350.     player.endurance=random(9)+20;
  351.     player.origendur=player.endurance;
  352.     printf("\n\nYour Combat skill is %d",player.combat_skill);
  353.     printf("\nYour Endurance is %d\n",player.endurance);
  354.     printf("Now type in your 5 disciplines according to the following table:\n");
  355.     printf("1-Camouflage\n2-Hunting\n3-Sixth Sense\n4-Tracking\n5-Healing\n");
  356.     printf("6-Weaponskill\n7-Mindshield\n8-Mindblast\n9-Animal Kinship\n10-Mind over matter\n");
  357.     printf("Your Location is now %d\n",player.location);
  358.     dis();
  359. }
  360.  
  361.  
  362.  
  363. dis()
  364. {
  365.     char ch[2],choice,ch1[2];
  366.     int num=1,ch2=7,x,y,chec;
  367.  
  368.  
  369.     printf("\n\nWhat number discipline\(1 to 5\) do you want to input\n");
  370.     printf("\(0 to quit, 6 to list disciplines,7 to list yours\)\n");
  371.     gets(ch1);
  372.     ch2=atoi(ch1);
  373.     if(ch2 > 7 || ch2<0)
  374.     {
  375.         printf("You must chose 0 to 7\n");
  376.         dis();
  377.     }
  378.     if(ch2 == 0)
  379.     {
  380.         printf("Are you sure you are done, this is the only time you can adjust these!!\n");
  381.         check();
  382.         choice=getche();
  383.         if(choice == 'y' || choice=='Y')
  384.         {
  385.             for(x=1;x<=5;x++)
  386.             {
  387.                 if(player.skill[x] == 6)
  388.                 {
  389.           player.weoponskill=random(9);
  390.                     y=player.weoponskill;
  391.                     printf("Your weoponskill is in %s\n",weopons[y]);
  392.                     money();
  393.                     chec = 1;
  394.                 }
  395.             }
  396.             if(chec != 1)
  397.             {
  398.         player.weoponskill=11;
  399.                 money();
  400.             }
  401.  
  402.         }
  403.      else dis();
  404.     }
  405.     if(ch2 == 6)
  406.     {
  407.         for(x=1;x<=10;x++)
  408.         {
  409.          printf("%d - %s\n",x,disciplines[x]);
  410.         }
  411.         dis();
  412.     }
  413.     if(ch2 == 7)
  414.     {
  415.         for(x=1;x<=5;x++)
  416.         {
  417.             y=player.skill[x];
  418.             printf("%d - %s\n",x,disciplines[y]);
  419.         }
  420.         dis();
  421.     }
  422.     printf("What is your  discipline?");
  423.     gets(ch);
  424.     num=atoi(ch);
  425.     if(num >= 11 || num<=0)
  426.     {
  427.         printf("\nThere are only 10 disciplines\n");
  428.         dis();
  429.     }
  430.     printf("Your %d discipline is %s, is this correct?",ch2,disciplines[num]);
  431.     check();
  432.     choice=getche();
  433.     if(choice == 'y' || choice=='Y')
  434.     {
  435.         player.skill[ch2]=num;
  436.         dis();
  437.     }
  438.     else dis();
  439.     check();
  440.     getche();
  441. }
  442.  
  443.  
  444. money()
  445. {
  446.   player.weopons[1]=6;
  447.     printf("\nYou    start out with a %s\n", weopons[6]);
  448.     player.money=random(9);
  449.     printf("You have %d Gold Crowns in a pouch at your waist\n",player.money);
  450.     player.food=1;
  451.   printf("Your Location is now %d\n",player.location);
  452.     printf("You have 1 meal \n");
  453.     special();
  454. }
  455.  
  456. special()
  457. {
  458.     int y,z;
  459.  
  460.     y=random(9);
  461.     if(y==1||y==5||y==7||y==8||y==0)
  462.     {
  463.         if(y==1) z=5;
  464.         if(y==5) z=2;
  465.         if(y==7) z=8;
  466.         if(y==8) z=1;
  467.         if(y==0) z=9;
  468.         player.weopons[2]=z;
  469.         printf("You also find a %s in the rubble\n",weopons[z]);
  470.     }
  471.     if(y==2)
  472.     {
  473.         player.special[1]=1;
  474.         printf("You find a helmet for your head in the rubble\n");
  475.     }
  476.     if(y==3)
  477.     {
  478.         player.food=player.food+2;
  479.         printf("You find two meals\n");
  480.     }
  481.     if(y==4)
  482.     {
  483.         player.special[1]=2;
  484.         printf("You find a chainmail waistcoat which you put on\n");
  485.     }
  486.     if(y==6)
  487.     {
  488.         player.special[1]=4;
  489.         printf("You find a healing potion \n");
  490.     }
  491.     if(y==9)
  492.     {
  493.         player.money=player.money+12;
  494.         printf("You find 12 gold crowns which brings your money to %d gold crowns",player.money);
  495.     }
  496.     check();
  497.     getche();
  498.     game();
  499. }
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507. game()
  508. {
  509.     int x,newroom=1;
  510.     char ch,new[3];
  511.  
  512.  
  513.     if(player.day!=date.da_day)
  514.     {
  515.         player.moves=30;
  516.         player.day=date.da_day;
  517.     }
  518.     printf(CLEAR);
  519.     printf("\n\nThe adventures of Silent Wolf Main Menu\n");
  520.     printf("---------------------------------------\n");
  521.     printf("   [1] Scores\n");
  522.     printf("   [2] Play Game\n");
  523.     printf("   [3] Your Stats\n");
  524.     printf("   [4] Take a Healing Potion\n");
  525.     printf("   [5] Quit\n");
  526.     printf("     Choice??");
  527.     check();
  528.     ch=getche();
  529.     switch(ch)
  530.     {
  531.         case  '1': Scores();
  532.                              game();
  533.                              break;
  534.         case  '2': play();
  535.                              break;
  536.         case  '3': stats();
  537.                              break;
  538.         case  '4': pot();
  539.                              break;
  540.         case  '5': end();
  541.                              break;
  542.         case '~':if(sl<100) game();
  543.                             printf("\nWhat room?");
  544.                             gets(new);
  545.                             newroom=atoi(new);
  546.                             player.location=newroom;
  547.                             printf("\nplayer location = %d",player.location);
  548.                             check();
  549.                             getche();
  550.                             game();
  551.                             break;
  552.         case '`': if(sl<100) game();
  553.                             printf("\nWhat special?");
  554.                             gets(new);
  555.                             newroom=atoi(new);
  556.                             player.special[4]=newroom;
  557.                             game();
  558.                             break;
  559.         case 'c':
  560.         case 'C': if(sl<100) game();
  561.                             printf("\nHow much money?");
  562.                             gets(new);
  563.                             newroom=atoi(new);
  564.                             player.money=newroom;
  565.                             game();
  566.                             break;
  567.         default:  game();
  568.     }
  569. }
  570.  
  571.  
  572.  
  573. pot()
  574. {
  575.     int x;
  576.     for(x=1;x<=100;x++)
  577.     {
  578.         if(player.special[x] == 4)
  579.         {
  580.             player.endurance=player.endurance+2;
  581.             player.special[x]=0;
  582.             printf("\n\nRestoring 2 endurance points\n");
  583.             check();
  584.             game();
  585.         }
  586.     }
  587.     printf("\n\nYou don't have a healing potion right now!!\n");
  588.     check();
  589.     game();
  590. }
  591.  
  592.  
  593.  
  594. end()
  595. {
  596.     FILE *fptr;
  597.     int x,offset,chec,y,slot,no=0;
  598.     char *die={"dead"};
  599.  
  600. printf(CLEAR);
  601. if(player.endurance<=0)
  602.     {
  603.         strcpy(player.name,die);
  604.         if(player.location != 350) printf("\n\nYou are dead!!\n");
  605.     }
  606. if(current == 0)
  607. {
  608.     if((fptr=fopen("players.sw","ab")) == NULL)
  609.     {
  610.         printf(" Can't open player file\n");
  611.         exit(1);
  612.     }
  613.     strcpy(player.name,name);
  614.   if(player.endurance<=0)
  615.     {
  616.         strcpy(player.name,die);
  617.         if(player.location !=350) printf("\n\nYou are dead!!\n");
  618.     }
  619.     fwrite(&player,sizeof(player),1,fptr);
  620.     fclose(fptr);
  621. }
  622. else
  623. {
  624.  if((fptr=fopen("players.sw","rb+")) == NULL)
  625.     {
  626.         printf(" Can't open player file\n");
  627.         exit(0);
  628.     }
  629. fseek(fptr,spot,0);
  630. fwrite(&player,sizeof(player),1,fptr);
  631. fclose(fptr);
  632. }
  633.     counter.count=store;
  634.     if((fptr=fopen("counters.sw","wb")) == NULL)
  635.             {
  636.                 printf(" Can't open counter file\n");
  637.                 exit(0);
  638.             }
  639.             else
  640.             {
  641.                 fwrite(&counter,sizeof(counter),1,fptr);
  642.             }
  643.     fclose(fptr);
  644.   if((fptr=fopen("scores.sw","rb")) == NULL)
  645.             {
  646.                 printf(" Can't open scores file\n");
  647.                 exit(0);
  648.             }
  649.     for(x=0;x<=9;x++)
  650.     {
  651.      fread(&scores[x],sizeof(scores[x]),1,fptr);
  652.     }
  653.     fclose(fptr);
  654.     if(player.score<=scores[9].score)
  655.     {
  656.     Scores();
  657.  
  658.     printf("\n\nThanks for Playing The Adventures of Lone Wolf\n\n");
  659.     printf("Come back soon to continue the adventure\n\n");
  660.     chdir(directory);
  661.     exit(0);
  662.     }
  663.     for(x=9;x>=0;x--)
  664.     {
  665.      if(player.score==scores[x].score&&(strcmp(name,scores[x].name))==0)no=1;
  666.      if(player.score>scores[x].score)slot=x;
  667.     }
  668.     if(no==0)
  669.     {
  670.         for(x=9;x>=slot;x--)
  671.         {
  672.          strcpy(scores[x].name,scores[x-1].name);
  673.          scores[x].score=scores[x-1].score;
  674.         }
  675.         strcpy(scores[slot].name,name);
  676.         scores[slot].score=player.score;
  677.         if((fptr=fopen("scores.sw","wb")) == NULL)
  678.             {
  679.                 printf(" Can't open scores file\n");
  680.                 exit(0);
  681.             }
  682.     for(x=0;x<=9;x++)
  683.     {
  684.      fwrite(&scores[x],sizeof(scores[x]),1,fptr);
  685.     }
  686.     fclose(fptr);
  687. }
  688.  
  689.  
  690.  
  691.     Scores();
  692.  
  693.     printf("\n\nThanks for Playing The Adventures of Lone Wolf\n\n");
  694.     printf("Come back soon to continue the adventure\n\n");
  695.     chdir(directory);
  696.     exit(0);
  697. }
  698.  
  699.  
  700.  
  701.  
  702. Scores()
  703. {
  704.     FILE *fptr;
  705.     int x;
  706.  
  707.     printf(CLEAR);
  708.     printf("\n\nScore Board\n\n");
  709.     if((fptr=fopen("scores.sw","rb")) == NULL)
  710.             {
  711.                 printf(" Can't open scores file\n");
  712.                 exit(0);
  713.             }
  714.     for(x=0;x<=9;x++)
  715.     {
  716.         fread(&scores[x],sizeof(scores[x]),1,fptr);
  717.         printf("%20s %10d\n",scores[x].name,scores[x].score);
  718.     }
  719.     printf("\n\n\n Press Enter to Continue>>>");
  720.     check();
  721.     getche();
  722.     return;
  723. }
  724.  
  725.  
  726. play()
  727. {
  728.     char ch[3],c,choice[5],file[80],*file1={"text1.sw"},
  729.                                                  *file2={"text2.sw"},
  730.                                                  *file3={"text3.sw"},
  731.                                                  *file4={"text4.sw"},
  732.                                                  *file5={"text5.sw"},
  733.                                                  *file6={"text6.sw"},
  734.                                                  *file7={"text7.sw"};
  735.  
  736.     int count=0,intchoice,c1=0,x;
  737.     FILE *fptr;
  738.  
  739.     printf(CLEAR);
  740.     if(player.moves<=0)
  741.     {
  742.         printf("You are out of moves for today, come back tommorow\n");
  743.         check();
  744.         game();
  745.     }
  746.     printf("You have %d moves left\n",player.moves);
  747.  
  748.  
  749.     stop=player.location;
  750.     if(stop>355) play();
  751.     read_room();
  752.  
  753.     if(stop<=50) strcpy(file,file1);
  754.     if(stop >50 && stop<=100){strcpy(file,file2); stop=stop-50;}
  755.     if(stop >100 && stop<=150){strcpy(file,file3);stop=stop-100;}
  756.     if(stop >150 && stop<=200){strcpy(file,file4);stop=stop-150;}
  757.     if(stop >200 && stop<=250){strcpy(file,file5);stop=stop-200;}
  758.     if(stop >250 && stop<=300){strcpy(file,file6);stop=stop-250;}
  759.     if(stop>300){strcpy(file,file7);stop=stop-300;}
  760.  
  761.  
  762.     if((fptr=fopen(file,"r")) == NULL)
  763.     {
  764.         printf(" Can't open text file\n");
  765.         exit(0);
  766.     }
  767.  
  768.     for(count=1;count<=stop;count++)
  769.     {
  770.         while((c=fgetc(fptr)) != '~' && (c!='@'));
  771.     }
  772.     while((c=fgetc(fptr)) != '~'&& (c!='@') && (c1 == 0))
  773.     {
  774.         putchar(c);
  775.         if(kbhit() != 0) c1=getche();
  776.     }
  777.     fclose(fptr);
  778.     if(player.location!=140&&player.location!=7&&player.location!=70&&player.location!=28)
  779.     {
  780.         player.score=player.score+1;
  781.     }
  782.     player.moves=player.moves-1;
  783.  
  784.     if(player.moves==4||player.moves==8||player.moves==12||player.moves==16||player.moves==20||player.moves==24||player.moves==28)
  785.     {
  786.         if(player.endurance<player.origendur)
  787.         {
  788.             for(x=1;x<=5;x++)
  789.             {
  790.                 if(player.skill[x]==5) player.endurance=player.endurance+1;
  791.             }
  792.         }
  793.     }
  794.  
  795.  
  796.     if(roomch.roomtype==1) type1(); /* go to rooms, choice rooms, chec disciplines*/
  797.     if(roomch.roomtype==2) type2(); /* random choice rooms*/
  798.     if(roomch.roomtype==3) type3(); /*combat sequences*/
  799.     if(roomch.roomtype==4) type4(); /*take weopon room*/
  800.     if(roomch.roomtype==33) type33();/*recieve money room*/
  801.     if(roomch.roomtype==9) type9();  /*possesion dependent room*/
  802.     if(roomch.roomtype==12) type12(); /*give money room*/
  803.     if(roomch.roomtype==20) type4();  /*take weopon and food*/
  804.     if(roomch.roomtype==29) type3();  /*combat with mindshield*/
  805.     if(roomch.roomtype==5) type5();  /*eat a meal*/
  806.     if(roomch.roomtype==99) type99(); /*die instantly*/
  807.     if(roomch.roomtype==6) type6();  /*take money and food*/
  808.     if(roomch.roomtype==7) type7();  /*take special room*/
  809.     if(roomch.roomtype==8) type8();   /*lose endurance*/
  810.     if(roomch.roomtype==10) type10();  /*take money and special*/
  811.     if(roomch.roomtype==144) type144();
  812.     if(roomch.roomtype==162) type162(); /*lose all backpack and weapons*/
  813.     if(roomch.roomtype==170) type170();  /*combat, lose combat skill if no torch*/
  814.     if(roomch.roomtype==274) type274();  /* lose weapons*/
  815.     if(roomch.roomtype==294) type294();  /*lose backpack and weapons, random choice*/
  816.     if(roomch.roomtype==304) type304();  /*take special and lose endurance*/
  817.     if(roomch.roomtype==350) type350();
  818.     if(roomch.roomtype==184) type4();
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.     else
  827.     {
  828.         printf("\nNot type 1\n");
  829.         check();
  830.         getche();
  831.         player.location=1;
  832.         play();
  833.     }
  834. }
  835.  
  836. stats()
  837. {
  838.     int y,x,z,wep,hold;
  839.  
  840.     printf(CLEAR);
  841.     printf("\n\n%s Stats...........\n",player.name);
  842.     printf("\nScore = %d\n",player.score);
  843.     printf("Endurance Limit = %d\n",player.origendur);
  844.     printf("Current Endurance = %d\n",player.endurance);
  845.     printf("Combat Skill = %d\n",player.combat_skill);
  846.   for(x=1;x<=5;x++)
  847.         {
  848.             y=player.skill[x];
  849.             printf("%d - %s\n",x,disciplines[y]);
  850.             if(y==6)
  851.             {
  852.              z=player.weoponskill;
  853.              printf("Skilled in %s\n",weopons[z]);
  854.              }
  855.         }
  856.  
  857.     for(x=1;x<=2;x++)
  858.     {
  859.         if(player.weopons[x] <= 10)
  860.         {
  861.             wep=player.weopons[x];
  862.             printf("You have a %s\n",weopons[wep]);
  863.         }
  864.     }
  865.     printf("You have %d meals\n",player.food);
  866.     for(x=0;x<=100;x++)
  867.     {
  868.         if(player.special[x] != 0)
  869.          {
  870.              hold=player.special[x];
  871.              printf("You have a %s\n",spec[hold]);
  872.          }
  873.     }
  874.     printf("You have %d Gold Crowns\n",player.money);
  875.     printf("Player Location = %d\n",player.location);
  876.     printf("Press enter to Continue>>>");
  877.     check();
  878.     getche();
  879.     game();
  880. }
  881.  
  882.  
  883. type1()
  884. {
  885.      int intchoice,chec=0,x;
  886.      char ch;
  887.  
  888.      if(player.endurance<=0) end();
  889.      printf("\nChoice(Q to quit)??");
  890.      check();
  891.      ch=getche();
  892.      switch(ch)
  893.      {
  894.         case '1': if(roomch.dis[1] != 0)
  895.                             {
  896.                                 for(x=1;x<=5;x++)
  897.                                 {
  898.                                     if(player.skill[x]==roomch.dis[1]) chec=1;
  899.                                 }
  900.                                 if(chec != 1) type1();
  901.                             }
  902.                             player.location=roomch.choice[1];
  903.                             play();
  904.                             break;
  905.         case '2': if(roomch.dis[2] != 0)
  906.                             {
  907.                                 for(x=1;x<=5;x++)
  908.                                 {
  909.                                     if(player.skill[x]==roomch.dis[2]) chec=1;
  910.                                 }
  911.                                 if(chec != 1) type1();
  912.                             }
  913.                             if(roomch.choice[2]==0) play();
  914.                             player.location=roomch.choice[2];
  915.                             play();
  916.                             break;
  917.         case '3': if(roomch.dis[3] != 0)
  918.                             {
  919.                                 for(x=1;x<=5;x++)
  920.                                 {
  921.                                     if(player.skill[x]==roomch.dis[3]) chec=1;
  922.                                 }
  923.                                 if(chec != 1) type1();
  924.                             }
  925.                             if(roomch.choice[3]==0) play();
  926.                             player.location=roomch.choice[3];
  927.                             play();
  928.                             break;
  929.         case '4': if(roomch.dis[4] != 0)
  930.                             {
  931.                                 for(x=1;x<=5;x++)
  932.                                 {
  933.                                     if(player.skill[x]==roomch.dis[4]) chec=1;
  934.                                 }
  935.                                 if(chec != 1) type1();
  936.                             }
  937.                             if(roomch.choice[4]==0) play();
  938.                             player.location=roomch.choice[4];
  939.                             play();
  940.                             break;
  941.         case 'Q':
  942.         case 'q': if(roomch.roomtype==1)game();
  943.                             else
  944.                             {
  945.                                 printf("You can't at this time, you must press on\nHit return>>");
  946.                                 check();
  947.                                 getche();
  948.                                 type1();
  949.                             }
  950.                             break;
  951.         default:  type1();
  952.      }
  953. }
  954.  
  955.  
  956. type2()
  957. {
  958.     int mytime,dice;
  959.  
  960.     printf("Hit Enter to continue");
  961.     check();
  962.     getche();
  963.     randomize();
  964.  
  965.     dice=random(9);
  966.     if(dice>=roomch.randlow[1] && dice<=roomch.randhi[1])
  967.         {
  968.             player.location=roomch.choice[1];
  969.             play();
  970.         }
  971.     if(dice>=roomch.randlow[2] && dice<=roomch.randhi[2])
  972.         {
  973.          player.location=roomch.choice[2];
  974.             play();
  975.         }
  976.     if(dice>=roomch.randlow[3] && dice<=roomch.randhi[3])
  977.         {
  978.          player.location=roomch.choice[3];
  979.             play();
  980.         }
  981. }
  982.  
  983. type3()
  984. {
  985.     int comskill,endure,ratio,enemy,lw,hiten,hitlw,x,y,r,mytime,chec=0;
  986.  
  987.  
  988.  
  989.  
  990.  
  991.     if(roomch.roomtype==29)
  992.     {
  993.         for(x=1;x<=5;x++)
  994.         {
  995.             if(player.skill[x]==7) chec=1;
  996.         }
  997.         if(chec!=1) comskill=player.combat_skill+roomch.comadder;
  998.         if(chec==1) comskill=player.combat_skill;
  999.     }
  1000.     if(roomch.roomtype!=29)
  1001.     {
  1002.         comskill=player.combat_skill+roomch.comadder;
  1003.     }
  1004.     if(player.weoponskill == player.weopons[1] ||player.weoponskill == player.weopons[2])
  1005.     {
  1006.         comskill=comskill+2;
  1007.     }
  1008.  
  1009.   for(x=1;x<=100;x++)
  1010.     {
  1011.         if(player.special[x] == 8) comskill=comskill+2;
  1012.     }
  1013.  
  1014.  
  1015.     endure=player.endurance+roomch.endadder;
  1016.     printf("\nYour combat skill for this fight is %d\n",comskill);
  1017.     printf("Your Endurance is %d\n",endure);
  1018.     for(x=4;x>=1;x--)
  1019.     {
  1020.         if(roomch.combat[x]==0)y=x;
  1021.     }
  1022.     for(x=1;x<y;)
  1023.     {
  1024.         ratio=comskill-roomch.combat[x];
  1025.         printf("\nEnemy 1--Combat skill - %d, Endurance - %d",roomch.combat[x],roomch.endurance[x]);
  1026.         enemy=roomch.endurance[x];
  1027.         lw=endure;
  1028.         while(enemy > 0 && lw > 0)
  1029.         {
  1030.             randomize();
  1031.             r=random(9);
  1032.             hiten=-2.48+(r*(-1.01))+(ratio*(-.514))+.5;
  1033.             hitlw=-6.31+(r*(.6742))+(ratio*(.273538))+.5;
  1034.             if(hitlw>=0) hitlw=0;
  1035.             enemy=enemy+hiten;
  1036.             lw=lw+hitlw;
  1037.             printf("\nHe hits you-->you have %d endurance left\n",lw);
  1038.             printf("You hit him-->he has %d endurance left\n",enemy);
  1039.             check();
  1040.             getche();
  1041.  
  1042.         }
  1043.         if(lw<=0)
  1044.         {
  1045.             player.endurance=lw;
  1046.             end();
  1047.         }
  1048.         player.endurance=lw;
  1049.         player.score=player.score+roomch.combat[x]+roomch.endurance[x];
  1050.         x=x+1;
  1051.         if(x==y)
  1052.         {
  1053.  
  1054.  
  1055.             if(roomch.roomnum==17) type2();
  1056.             else type1();
  1057.         }
  1058.     }
  1059. }
  1060.  
  1061. type4()
  1062. {
  1063.     int what,x,old,new;
  1064.     char ch1,ch,ch2;
  1065.  
  1066.     if(roomch.roomtype==184)
  1067.     {
  1068.     player.food=player.food+roomch.foodin;
  1069.     player.money=player.money+roomch.moneyin;
  1070.     }
  1071.  
  1072.     if(roomch.weaponin!=12)
  1073.     {
  1074.         what=roomch.weaponin;
  1075.         if(player.weopons[1] == roomch.weaponin || player.weopons[2] ==roomch.weaponin)
  1076.         {
  1077.      if(roomch.roomtype==20)food();
  1078.          type1();
  1079.         }
  1080.         printf("Would you like to take the %s\n",weopons[what]);
  1081.         check();
  1082.         ch=getche();
  1083.         if(ch!='y' && ch!='Y')
  1084.         {
  1085.          if(roomch.roomtype==20)food();
  1086.          type1();
  1087.         }
  1088.         if(player.weopons[1] <= 10 && player.weopons[2] <=10)
  1089.         {
  1090.             printf("\nYou already have 2 weopons\n");
  1091.             printf("Would you like to leave one?");
  1092.             check();
  1093.             ch1=getche();
  1094.             if(ch1 != 'y' && ch1 != 'Y') type1();
  1095.             for(x=1;x<=2;x++)
  1096.             {
  1097.                 old=player.weopons[x];
  1098.                 new=roomch.weaponin;
  1099.                 printf("\nWould you switch the %s for the %s",weopons[old],weopons[new]);
  1100.                 check();
  1101.                 ch2=getche();
  1102.                 if(ch2=='y'||ch2=='Y')
  1103.                 {
  1104.                     player.weopons[x]=roomch.weaponin;
  1105.           if(roomch.roomtype==20)food();
  1106.                     type1();
  1107.                 }
  1108.             }
  1109.             if(roomch.roomtype==20)food();
  1110.             type1();
  1111.         }
  1112.         else
  1113.         {
  1114.             if(player.weopons[2]<=10) player.weopons[2]=roomch.weaponin;
  1115.             if(roomch.roomtype==20)food();
  1116.             type1();
  1117.         }
  1118.     }
  1119. }
  1120.  
  1121. type5()
  1122. {
  1123.     eat();
  1124.     type1();
  1125. }
  1126.  
  1127. type6()
  1128. {
  1129.     player.money=player.money+roomch.moneyin;
  1130.     player.score=player.score+roomch.moneyin;
  1131.     food();
  1132.     type1();
  1133. }
  1134.  
  1135. type7()
  1136. {
  1137.     take_special();
  1138.     type1();
  1139. }
  1140.  
  1141.  
  1142. take_special()
  1143. {
  1144.     int x=0,y;
  1145.     while(player.special[x]!=0)
  1146.     {
  1147.         x++;
  1148.     }
  1149.     player.special[x]=roomch.specialin;
  1150.     player.score=player.score+10;
  1151.     return;
  1152. }
  1153.  
  1154. type8()
  1155. {
  1156.     player.endurance=player.endurance+roomch.endadder;
  1157.     type1();
  1158. }
  1159.  
  1160. type9()
  1161. {
  1162.     int x,n,num,y,chec;
  1163.     char ch[3];
  1164.  
  1165.     printf("Choice?");
  1166.     gets(ch);
  1167.     num=atoi(ch);
  1168.     if(num==2)
  1169.     {
  1170.          if(roomch.dis[2] != 0)
  1171.             {
  1172.                 for(x=1;x<=5;x++)
  1173.                 {
  1174.                     if(player.skill[x]==roomch.dis[2]) chec=1;
  1175.                 }
  1176.             if(chec != 1) type9();
  1177.             }
  1178.          if(roomch.choice[2]==0) type9();
  1179.          player.location=roomch.choice[2];
  1180.          play();
  1181.     }
  1182.     if(num==3)
  1183.     {
  1184.     if(roomch.dis[3] != 0)
  1185.             {
  1186.                 for(x=1;x<=5;x++)
  1187.                 {
  1188.                     if(player.skill[x]==roomch.dis[3]) chec=1;
  1189.                 }
  1190.                 if(chec != 1) type9();
  1191.             }
  1192.             if(roomch.choice[3]==0) type9();
  1193.             player.location=roomch.choice[3];
  1194.             play();
  1195.     }
  1196.  
  1197.     for(x=0;x<=100;x++)
  1198.      {
  1199.         if(player.special[x] == roomch.specialuse)
  1200.         {
  1201.             player.location=roomch.choice[1];
  1202.             player.score=player.score+25;
  1203.             play();
  1204.         }
  1205.      }
  1206.      n=roomch.specialuse;
  1207.      printf("\nYou don't have a %s\n",spec[n]);
  1208.      check();
  1209.      getche();
  1210.      type9();
  1211. }
  1212.  
  1213.  
  1214. type10()
  1215. {
  1216.  take_special();
  1217.  type33();
  1218. }
  1219.  
  1220. type12()
  1221. {
  1222.     int num,x,chec;
  1223.     char ch[3];
  1224.  
  1225.     printf("choice??");
  1226.   gets(ch);
  1227.     num=atoi(ch);
  1228.     if(num==2)
  1229.     {
  1230.      if(roomch.dis[2] != 0)
  1231.                             {
  1232.                                 for(x=1;x<=5;x++)
  1233.                                 {
  1234.                                     if(player.skill[x]==roomch.dis[2]) chec=1;
  1235.                                 }
  1236.                                 if(chec != 1) type12();
  1237.                             }
  1238.             if(roomch.choice[2]==0) type12();
  1239.          player.location=roomch.choice[2];
  1240.          play();
  1241.     }
  1242.     if(num==3)
  1243.     {
  1244.     if(roomch.dis[3] != 0)
  1245.                             {
  1246.                                 for(x=1;x<=5;x++)
  1247.                                 {
  1248.                                     if(player.skill[x]==roomch.dis[3]) chec=1;
  1249.                                 }
  1250.                                 if(chec != 1) type12();
  1251.                             }
  1252.                             if(roomch.choice[3]==0) type12();
  1253.                             player.location=roomch.choice[3];
  1254.                             play();
  1255.     }
  1256.     if(roomch.moneyuse>player.money)
  1257.     {
  1258.         printf("You don't have enough money\ntry again\n");
  1259.         check();
  1260.         getche();
  1261.         type12();
  1262.     }
  1263.     player.location=roomch.choice[1];
  1264.     player.money=player.money-roomch.moneyuse;
  1265.     play();
  1266. }
  1267.  
  1268.  
  1269.  
  1270.  
  1271. type33()
  1272. {
  1273.      player.money=player.money+roomch.moneyin;
  1274.      player.score=player.score+roomch.moneyin;
  1275.      type1();
  1276. }
  1277.  
  1278. type99()
  1279. {
  1280.     printf("\nYour mission has Ended!!!\nHit enter to continue");
  1281.     player.endurance=-1;
  1282.     player.score=player.score-10;
  1283.     check();
  1284.     end();
  1285. }
  1286.  
  1287. type144()
  1288. {
  1289.     eat();
  1290.     type8();
  1291. }
  1292.  
  1293. type162()
  1294. {
  1295.     int x;
  1296.  player.food=0;
  1297.  player.weopons[1]=12;
  1298.  player.weopons[2]=12;
  1299.  player.score=player.score-10;
  1300.  for(x=0;x<=100;x++)
  1301.  {
  1302.     player.special[x]=0;
  1303.  }
  1304.  type1();
  1305. }
  1306.  
  1307. type170()
  1308. {
  1309.     int x;
  1310.  
  1311.     for(x=0;x<=100;x++)
  1312.     {
  1313.         if(player.special[x]==9) type3();
  1314.     }
  1315.     roomch.comadder=-3;
  1316.     type3();
  1317. }
  1318.  
  1319. type274()
  1320. {
  1321.     player.weopons[1]=12;
  1322.     player.weopons[2]=12;
  1323.     player.score=player.score-10;
  1324.     type(1);
  1325. }
  1326.  
  1327. type294()
  1328. {
  1329.     int x;
  1330.  
  1331.  player.food=0;
  1332.  player.weopons[1]=12;
  1333.  player.weopons[2]=12;
  1334.  player.score=player.score-15;
  1335.  for(x=0;x<=100;x++)
  1336.  {
  1337.     player.special[x]=0;
  1338.  }
  1339.  type2();
  1340. }
  1341.  
  1342. type304()
  1343. {
  1344.     take_special();
  1345.     type8();
  1346. }
  1347.  
  1348. type350()
  1349. {
  1350.     int x;
  1351.     printf("\n\n\nYou win!!!!\n\n\n");
  1352.   for(x=0;x<=100;x++)
  1353.  {
  1354.     if(player.special[x]!=0)player.score=player.score+20;
  1355.  }
  1356.  
  1357.     if(player.weopons[1]!=12)player.score=player.score+10;
  1358.     if(player.weopons[2]!=12)player.score=player.score+10;
  1359.     player.score=player.score+player.money;
  1360.     player.score=player.score+(player.food*10);
  1361.     player.score=player.score+100;
  1362.  
  1363.     player.location=1;
  1364.     printf("Your final score was %d\n\n",player.score);
  1365.     check();
  1366.     player.endurance=-2;
  1367.     end();
  1368. }
  1369.  
  1370.  
  1371. food()
  1372. {
  1373.     player.food=player.food+roomch.foodin;
  1374.     player.food=player.food-roomch.fooduse;
  1375.     player.score=player.score+10;
  1376.     player.money=player.money+roomch.moneyin;
  1377.     type1();
  1378. }
  1379.  
  1380.  
  1381. read_room()
  1382. {
  1383.     FILE *fptr;
  1384.     int x,offset;
  1385.  
  1386.   if((fptr=fopen("rooms.sw","rb")) == NULL)
  1387.     {
  1388.         printf(" Can't open text file\n");
  1389.         exit(0);
  1390.     }
  1391.     else
  1392.     {
  1393.         offset=0;
  1394.         for(x=0;x<=360;x++)
  1395.         {
  1396.             if(x!=0)
  1397.             {
  1398.                 offset=x*sizeof(roomch);
  1399.                 fseek(fptr,offset,0);
  1400.             }
  1401.             fread(&roomch,sizeof(roomch),1,fptr);
  1402.             if(roomch.roomnum==stop)
  1403.             {
  1404.                 fclose(fptr);
  1405.                 return;
  1406.             }
  1407.         }
  1408.     }
  1409.  fclose(fptr);
  1410. }
  1411.  
  1412. eat()
  1413. {
  1414.     int x;
  1415.  
  1416.     for(x=1;x<=5;x++)
  1417.     {
  1418.         if(player.skill[x]==2) return;
  1419.     }
  1420.   if(player.food==0)
  1421.     {
  1422.          player.endurance=player.endurance-3;
  1423.          printf("You lose 3 endurance points for having no food\n");
  1424.     }
  1425.     if(player.food>=1)
  1426.     {
  1427.         player.food=player.food-1;
  1428.         player.score=player.score+10;
  1429.         printf("You have %d meals left\n",player.food);
  1430.     }
  1431.     if(player.endurance<=0)
  1432.     {
  1433.         printf("You have no Endurance left-->YOU DIE\nHit enter to Continue");
  1434.         check();
  1435.          end();
  1436.     }
  1437.     return;
  1438. }
  1439.  
  1440. check()
  1441. {
  1442.  time_t tstart,tstop;
  1443.  long tused;
  1444.  
  1445.  time(&tstart);
  1446.  while (!kbhit())
  1447.  {
  1448.      time(&tstop);
  1449.      tused=difftime(tstop,tstart);
  1450.      if(tused>=180) exit(1);
  1451.  }
  1452.  return;
  1453. }
  1454.  
  1455.  
  1456. type(file)
  1457. char *file[];
  1458. {
  1459.   FILE *fptr;
  1460.     char c,string[81];
  1461.     int c1=0;
  1462.  
  1463.   if((fptr=fopen(*file,"r")) == NULL)
  1464.   {
  1465.     printf("File Doesn't exist");
  1466.         printf("Press Return>");
  1467.         check();
  1468.         getche();
  1469.         exit(0);
  1470.     }
  1471.     while((c=fgetc(fptr))!='@'&& (c1 == 0))
  1472.     {
  1473.         putchar(c);
  1474.         if(kbhit()) c1=getche();
  1475.     }
  1476.     fclose(fptr);
  1477. }