home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / vmsnet / vmsspace / part05 < prev    next >
Internet Message Format  |  1993-06-06  |  24KB

  1. Path: uunet!mcsun!chsun!pega!dr_who
  2. From: dr_who@pegasus.ch (Sysop of PEGASUS)
  3. Newsgroups: vmsnet.sources.games
  4. Subject: SPCEMP.C   Part 05/06
  5. Message-ID: <1993Jun7.093332.126@pegasus.ch>
  6. Date: 7 Jun 93 09:33:32 +0200
  7. Organization: Pegasus BBS, Switzerland
  8. Lines: 852
  9. Xref: uunet vmsnet.sources.games:738
  10.  
  11. ----> START OF PART 5 <----
  12. /********************************************************************/
  13. news(int msg,char string[80])
  14. {
  15. char ostring[80],zstring[80];
  16.  
  17. sprintf(zstring,"SPCEMP:News.TXT");
  18.  
  19. switch(msg) {
  20.     case 1: sprintf(ostring,"%s defeated %s!",player[pn].player,player[epn].player);
  21.         optlog(ostring,zstring);
  22.         break;
  23.     case 2: sprintf(ostring,"%s repelled an attack from %s!",player[epn].player,player[pn].player);
  24.         optlog(ostring,zstring);
  25.         break;
  26.     case 3: sprintf(ostring,"%s crushed %s!",player[pn].player,player[epn].player);
  27.         optlog(ostring,zstring);
  28.         break;
  29.     case 5: sprintf(ostring,"%s was caught spying on %s!",player[pn].player,player[epn].player);
  30.         optlog(ostring,zstring);
  31.         break;
  32.     case 6: sprintf(ostring,"%s was torn in half by civil war!",player[pn].player);
  33.         optlog(ostring,zstring);
  34.         break;
  35.     case 7: sprintf(ostring,"%s joined the %s alliance.",player[pn].player,player[pn].teamname);
  36.         optlog(ostring,zstring);
  37.         break;
  38.     case 8: sprintf(ostring,"%s withdrew from the %s alliance.",player[pn].player,player[pn].teamname);
  39.         optlog(ostring,zstring);
  40.         break;
  41.     case 9: sprintf(ostring,"The %s alliance was dissolved.",player[pn].teamname);
  42.         optlog(ostring,zstring);
  43.         break;
  44.     case 11:sprintf(ostring,"%s: %s",player[pn].player,string);
  45.         optlog(ostring,zstring);
  46.         break;
  47.     case 12:sprintf(ostring,"%s was expelled from the %s alliance.",player[epn].player,player[pn].teamname);
  48.         optlog(ostring,zstring);
  49.         break;
  50.     case 20:sprintf(ostring,"%s transferd %s credits to %s`s account.",player[pn].player,string,player[epn].player);
  51.         optlog(ostring,zstring);
  52.         break;
  53.     case 41:sprintf(ostring,"%s tried to steal %s's Freighters !",player[pn].player,player[epn].player);
  54.         optlog(ostring,zstring);
  55.         break;
  56.     case 40:sprintf(ostring,"%s tried to steal %s's Y-Wing-Fighters !",player[pn].player,player[epn].player);
  57.         optlog(ostring,zstring);
  58.         break;
  59.     case 46:sprintf(ostring,"%s stole %s of %s's Freighters !",player[pn].player,string,player[epn].player);
  60.         optlog(ostring,zstring);
  61.         break;
  62.     case 45:sprintf(ostring,"%s stole %s of %s's Y-Wing-Fighters !",player[pn].player,string,player[epn].player);
  63.         optlog(ostring,zstring);
  64.         break;
  65.     case 50:sprintf(ostring,"%s joined the game !!  ( WELCOME !! ) ",player[pn].player);
  66.         optlog(ostring,zstring);
  67.         break;
  68.     case 51:sprintf(ostring,"%s finaly died !!",player[pn].player);
  69.         optlog(ostring,zstring);
  70.         break;
  71.     case 52:sprintf(ostring,"%s commit suicide !!",player[pn].player);
  72.         optlog(ostring,zstring);
  73.         break;
  74.     case 102:sprintf(ostring,"%s's Anti-Matter Bomb exploded on a planet from %s !!",player[pn].player,player[epn].player);
  75.         optlog(ostring,zstring);
  76.         break;
  77.     case 103:sprintf(ostring,"Missiles from %s destroyed 30 %% of %s's population. \n",player[pn].player,player[epn].player);
  78.         optlog(ostring,zstring);
  79.         break;
  80.     case 104:sprintf(ostring,"Missiles from %s destroyed 100 %% of %s's foodproduction. \n",player[pn].player,player[epn].player);
  81.         optlog(ostring,zstring);
  82.         break;
  83.     case 105:sprintf(ostring,"Missiles from %s destroyed 50 %% of %s's army. \n",player[pn].player,player[epn].player);
  84.         optlog(ostring,zstring);
  85.         break;
  86.     case 106:sprintf(ostring,"Missiles from %s destroyed 50 %% of %s's Gov. Planets. \n",player[pn].player,player[epn].player);
  87.         optlog(ostring,zstring);
  88.         break;
  89.     case 108:
  90.     case 109:sprintf(ostring,"%s sent a mole to %s.",player[pn].player,player[epn].player);
  91.         optlog(ostring,zstring);
  92.         break;
  93.     case 153:sprintf(ostring,"%s repelled a thermonuclear missile attack from %s.\n",player[epn].player,player[pn].player);
  94.         optlog(ostring,zstring);
  95.         break;
  96.     case 154:sprintf(ostring,"%s repelled a chemical missile attack from %s.\n",player[epn].player,player[pn].player);
  97.         optlog(ostring,zstring);
  98.         break;
  99.     case 155:sprintf(ostring,"%s repelled a convetional missile attack from %s.\n",player[epn].player,player[pn].player);
  100.         optlog(ostring,zstring);
  101.         break;
  102.     case 156:sprintf(ostring,"%s repelled an anti-matter missile attack from %s.\n",player[epn].player,player[pn].player);
  103.         optlog(ostring,zstring);
  104.         break;
  105.     case 201:sprintf(ostring,"%s throw %s down from the uridium throne.",player[pn].player,player[epn].player);
  106.         optlog(ostring,zstring);
  107.         break;
  108.     case 202:sprintf(ostring,"%s wins a place at the uridium throne.",player[pn].player);
  109.         optlog(ostring,zstring);
  110.         break;
  111.     case 203:sprintf(ostring,"%s lose his place at the uridium throne.",player[pn].player);
  112.         optlog(ostring,zstring);
  113.         break;
  114.  
  115.     case 999: sprintf(ostring,"%s played some turns ",player[pn].player);
  116.           optlog(ostring,zstring);
  117.           break;
  118.  
  119.     }
  120. }
  121.  
  122. /********************************************************************/
  123. optlog(char string[80],char logue[80])
  124. {
  125.   time_t  zeit;
  126.   char    *t[19];
  127.   FILE    *logf;
  128.  
  129.   zeit = time (&zeit);
  130.   strncpy(t,ctime(&zeit),19);                /* NOT AN ANSI STANDART */
  131.  
  132.   if(check_file(logue)==FALSE)
  133.     logf=fopen(logue,"w");
  134.   else
  135.     logf=fopen(logue,"a");
  136.  
  137. fprintf(logf,"[%s] ",t);
  138. fputs(string,logf);
  139. fputs("\n",logf);
  140. fclose(logf);
  141. }
  142.  
  143. /*****************************************************************/
  144. check_stringinfile(char filename[80],char string[150])
  145. {
  146. FILE *fp;
  147. char line[80];
  148.  
  149. fp=fopen(filename,"r");
  150.  do 
  151.  {
  152.    fgets(line,80,fp);
  153.    strip_crlf(line);
  154.    if(strstr(line,string)>0)
  155.     {
  156.     fclose(fp);
  157.     return(TRUE);
  158.     }
  159.  } while (feof(fp)==FALSE);
  160.  
  161. fclose(fp);
  162. return(FALSE);
  163. }
  164.  
  165. /*****************************************************************/
  166. get_score(int nr)
  167. {
  168. player[nr].score = 0;
  169. /* planets * 100 */
  170. player[nr].score = player[nr].score + (100 * (player[nr].defensep + player[nr].orep + player[nr].foodp + player[nr].governp + player[nr].tradep + player[nr].tourismp));
  171. /* get army score */
  172. player[nr].score = player[nr].score + (player[nr].soldiers + player[nr].cruisers*3 + player[nr].fighters*2 + player[nr].defense*2 + player[nr].ywings*3 + player[nr].missiledefense);
  173. /* get army score 2 + pilots / freighters */
  174. player[nr].score = player[nr].score + (player[nr].agents*2 + player[nr].carriers*3 + player[nr].pilots + player[nr].freighters*2 );
  175.  
  176. /** MONEY addjustments **/
  177. player[nr].score = player[nr].score + (player[nr].credits/1000 + player[nr].acredits/900);
  178.  
  179. /**/
  180. if(player[nr].score_modifier>0) 
  181.     player[nr].score = player[nr].score + player[nr].score_modifier;
  182. if(player[nr].score<0) 
  183.     player[nr].score=0;
  184. }
  185.  
  186. /*****************************************************************/
  187. points(int status)
  188. {
  189. int found=FALSE;
  190. int z=0;
  191. int x=0;
  192. FILE *fp;
  193. char line[80][500];
  194. char prot[2]=" ";
  195. char temp_player[30];
  196.  
  197. if (player[pn].protection!=0)
  198.     strcpy(prot,"*");
  199.  
  200. get_score(pn);
  201.  
  202. if (player[pn].score>=uridium_limit)
  203.     strcpy(prot,"#");
  204.  
  205. if(check_file("SPCEMP:PLAYERS.SCORES")==FALSE)
  206.  {
  207.   sleep(1);
  208.   if(check_file("SPCEMP:PLAYERS.SCORES")==FALSE)
  209.    {
  210.     fp=fopen("SPCEMP:PLAYERS.SCORES","w");
  211.       fprintf(fp,"-+-"); 
  212.     fclose(fp);
  213.    }
  214.  }
  215.  
  216. fp=fopen("SPCEMP:PLAYERS.SCORES","r");
  217.  do 
  218.  {
  219.    z++;
  220.    fgets(line[z],80,fp);
  221.    strip_crlf(line[z]);
  222.  } while (strpbrk(line[z],"+")==0);
  223. fclose(fp);
  224.  
  225. if(check_file("SPCEMP:PLAYERS.SCORES")==TRUE)
  226.   delete_file("SPCEMP:PLAYERS.SCORES");
  227. fp=fopen("SPCEMP:PLAYERS.SCORES","w");
  228. for(x=1;x<z;x++)
  229.  {
  230.   sscanf(line[x],"%s",&temp_player);
  231.      if((strcmp(temp_player,player[pn].player)==0)&&(status==1)) /* UPDATE */
  232.        {
  233.        sprintf(line[x],"%-20s |%9ld planets| %9ld pts. | %4ld moves | %2s",player[pn].player,(player[pn].orep+player[pn].defensep+player[pn].foodp+player[pn].tradep+player[pn].tourismp+player[pn].governp),player[pn].score,player[pn].played_moves,prot);
  234.        fprintf(fp,"%s\n",line[x]); 
  235.        found=TRUE;
  236.        }
  237.      else 
  238.        fprintf(fp,"%s\n",line[x]); 
  239.  
  240.  }
  241.  
  242. if((status==3)||((status==1)&&(found==FALSE))) /* ADD */
  243.   {
  244.   x++;
  245.   sprintf(line[x],"%-20s |%9ld planets| %9ld pts. | %4ld moves | %2s",player[pn].player,(player[pn].orep+player[pn].defensep+player[pn].foodp+player[pn].tradep+player[pn].tourismp+player[pn].governp),player[pn].score,player[pn].played_moves,prot);
  246.   fprintf(fp,"%s\n",line[x]); 
  247.   }
  248. fprintf(fp,"-+-\n");
  249. fclose(fp);
  250.  
  251. }
  252.  
  253. /********************************************************************/
  254. remove_player()
  255. {
  256. int z=0;
  257. int x=0;
  258. FILE *fp;
  259. char line[80][500];
  260. char ostring[80];
  261. char temp_player[30];
  262.  
  263. if(check_file("SPCEMP:PLAYERS.SCORES")==FALSE)
  264.  {
  265.   sleep(1);
  266.   if(check_file("SPCEMP:PLAYERS.SCORES")==FALSE)
  267.    {
  268.     fp=fopen("SPCEMP:PLAYERS.SCORES","w");
  269.       fprintf(fp,"-+-"); 
  270.     fclose(fp);
  271.    }
  272.  }
  273.  
  274. fp=fopen("SPCEMP:PLAYERS.SCORES","r");
  275.  do 
  276.  {
  277.    z++;
  278.    fgets(line[z],80,fp);
  279.    strip_crlf(line[z]);
  280.  } while (strpbrk(line[z],"+")==0);
  281. fclose(fp);
  282.  
  283.  
  284. if(check_file("SPCEMP:PLAYERS.SCORES")==TRUE)
  285.   delete_file("SPCEMP:PLAYERS.SCORES");
  286. fp=fopen("SPCEMP:PLAYERS.SCORES","w");
  287. for(x=1;x<z;x++)
  288.  {
  289.   sscanf(line[x],"%s",&temp_player);
  290.      if((strcmp(temp_player,player[pn].player)==0)&&(status==1)) /* UPDATE */
  291.     ;
  292.      else
  293.        fprintf(fp,"%s\n",line[x]); 
  294.  
  295.  }
  296.  
  297. fprintf(fp,"-+-\n");
  298. fclose(fp);
  299.  
  300. x=0;
  301. z=0;
  302. if(check_file("SPCEMP:LOTTERY.USER")==FALSE)
  303.  {
  304.   sleep(1);
  305.   if(check_file("SPCEMP:LOTTERY.USER")==FALSE)
  306.    {
  307.     fp=fopen("SPCEMP:LOTTERY.USER","w");
  308.     fclose(fp);
  309.    }
  310.  }
  311.  
  312. fp=fopen("SPCEMP:LOTTERY.USER","r");
  313. while(feof(fp)==FALSE)
  314.  {
  315.    z++;
  316.    fgets(line[z],80,fp);
  317.    strip_crlf(line[z]);
  318.  }
  319. fclose(fp);
  320.  
  321.  
  322. if(check_file("SPCEMP:LOTTERY.USER")==TRUE)
  323.   delete_file("SPCEMP:LOTTERY.USER");
  324. fp=fopen("SPCEMP:LOTTERY.USER","w");
  325. for(x=1;x<z;x++)
  326.  {
  327.   sscanf(line[x],"%s",&temp_player);
  328.      if((strcmp(temp_player,player[pn].player)==0)&&(status==1)) /* UPDATE */
  329.     ;
  330.      else
  331.        fprintf(fp,"%s\n",line[x]); 
  332.  
  333.  }
  334.  
  335. fclose(fp);
  336.  
  337. sprintf(ostring,"SPCEMP_PLAYERS:MSG_%s.TXT",player[pn].player);
  338. delete(ostring);
  339. sprintf(ostring,"SPCEMP_PLAYERS:%s.SDAT",player[pn].player);
  340. delete(ostring);
  341. sprintf(ostring,"SPCEMP_PLAYERS:%s.TRADE",player[pn].player);
  342. delete(ostring);
  343.  
  344. }
  345.  
  346. /********************************************************************/
  347. e_points(int status)
  348. {
  349. int z=0;
  350. int x=0;
  351. FILE *fp;
  352. char line[80][500];
  353. char prot[2]=" ";
  354. char temp_player[30];
  355.  
  356. if (player[epn].protection!=0)
  357.     strcpy(prot,"*");
  358.  
  359. get_score(epn);
  360.  
  361. if(check_file("SPCEMP:PLAYERS.SCORES")==FALSE)
  362.  {
  363.   sleep(1);
  364.   if(check_file("SPCEMP:PLAYERS.SCORES")==FALSE)
  365.    {
  366.     fp=fopen("SPCEMP:PLAYERS.SCORES","w");
  367.       fprintf(fp,"-+-"); 
  368.     fclose(fp);
  369.    }
  370.  }
  371.  
  372. fp=fopen("SPCEMP:PLAYERS.SCORES","r");
  373.  do 
  374.  {
  375.    z++;
  376.    fgets(line[z],80,fp);
  377.    strip_crlf(line[z]);
  378.  } while (strpbrk(line[z],"+")==0);
  379. fclose(fp);
  380.  
  381. if(check_file("SPCEMP:PLAYERS.SCORES")==TRUE)
  382.   delete_file("SPCEMP:PLAYERS.SCORES");
  383. fp=fopen("SPCEMP:PLAYERS.SCORES","w");
  384. for(x=1;x<z;x++)
  385.  {
  386.   sscanf(line[x],"%s",&temp_player);
  387.      if((strcmp(temp_player,player[epn].player)==0)&&(status==1)) /* UPDATE */
  388.        {
  389.        sprintf(line[x],"%-20s |%9ld planets| %9ld pts. | %4ld moves | %2s",player[epn].player,(player[epn].orep+player[epn].defensep+
  390.        player[epn].foodp+player[epn].tradep+player[epn].tourismp+player[epn].governp),player[epn].score,player[epn].played_moves,prot);
  391.        fprintf(fp,"%s\n",line[x]); 
  392.        }
  393.       else
  394.      if((strcmp(temp_player,player[epn].player)!=0)&&(status!=3)) /* THE NORMAL ONES */
  395.        fprintf(fp,"%s\n",line[x]); 
  396.  }
  397.  
  398. fprintf(fp,"-+-\n");
  399. fclose(fp);
  400.  
  401. }
  402.  
  403. /*****************************************************************/
  404. int check_player(char *playername)
  405. {
  406. char ostring[80];
  407.  
  408. sprintf(ostring,"SPCEMP_PLAYERS:%s.sdat",playername);
  409. return(check_file(ostring));
  410.  
  411. }
  412.  
  413. /*****************************************************************/
  414. display_users()
  415. {
  416. cls();
  417. printf("\n\nSpace Empire V%s list of scores\n",version);
  418. printf("----------------------------------------------------------------------------\n");
  419. printf("Name                       Planets          Score          Moves\n");
  420. printf("----------------------------------------------------------------------------\n");
  421. display_file("spcemp:players.scores",MORE);
  422. printf("----------------------------------------------------------------------------\n");
  423. }
  424.  
  425. /*****************************************************************/
  426. show_info()
  427. {
  428. char ostring[80];
  429. FILE *fp;
  430.  
  431. printf("\nRead documentation? [y/N] ");
  432. gets(ostring);
  433. ostring[0]=toupper(ostring[0]);
  434. if(ostring[0]!='Y') 
  435.     printf("");
  436. else 
  437.     display_file("SPCEMP:SPCEMP.DOC",MORE);
  438.  
  439. /* NEWS FILE */
  440.  
  441. if(check_file("SPCEMP:NEWS.TXT")==TRUE)
  442.     {
  443.     printf("\nRead NEWS-FILE? [y/N] ");
  444.     gets(ostring);
  445.     ostring[0]=toupper(ostring[0]);
  446.     if(ostring[0]!='Y') 
  447.         printf("");
  448.     else 
  449.         {
  450.         printf("\n\n");
  451.         display_file("SPCEMP:NEWS.TXT",MORE);
  452.         printf("\n\n");
  453.         press_return();
  454.         }
  455.     }
  456.  
  457. /* PRIV MSG */
  458.  
  459. sprintf(ostring,"SPCEMP_PLAYERS:MSG_%s.TXT",player[pn].player);
  460. printf("\n");
  461. display_file(ostring,MORE);
  462. printf("\n");
  463. press_return();
  464.  
  465. }
  466.  
  467. /*****************************************************************/
  468. bye()
  469. {
  470. int busy=FALSE;
  471. FILE *fp;
  472. char ostring[90];
  473.  
  474. points(1);
  475. cls();
  476.  
  477. if((player[pn].governp+player[pn].defensep+player[pn].foodp+player[pn].orep+player[pn].tourismp+player[pn].tradep)<=10)
  478.     {
  479.     player[pn].protection=0;
  480.     put_datas(pn);
  481.     }
  482.  
  483. printf("\n\n\nVAX-SPACE-EMPIRE V %s by %sR.Sieber%s & %sN.Kuemin%s \n\n",version,ansi(TT_BOLD),ansi(TT_RESET),ansi(TT_BOLD),ansi(TT_RESET));
  484. printf("I hope you like the game !!\n\n");
  485. printf("Your score is : %d Points\n\n",player[pn].score);
  486. if(player[pn].moves!=0)
  487.   printf("\n\nYou have %d moves left today.\n\n\n",player[pn].moves);
  488. else
  489.   {
  490.   printf("\n\nSorry but you are out of moves.\n");
  491.   printf("\nSee you tomorrow !\n\n");
  492.   }
  493.   if(check_file("SPCEMP:BUSY.STATUS")==TRUE)
  494.     delete_file("SPCEMP:BUSY.STATUS");
  495.   fp = fopen("SPCEMP:BUSY.STATUS", "w");
  496.    fprintf(fp,"%d\n",busy);
  497.    fprintf(fp,"%s\n",player[pn].player);
  498.   fclose(fp);
  499.  
  500.  
  501.   fclose(busy_fp);
  502.   delete_file("spcemp:in.use;1");
  503.  
  504.  
  505. exit(0);
  506. }
  507.  
  508.  
  509. /*****************************************************************/
  510. /*Lottery winner    looks for a new winner at the lottery     */
  511. /*****************************************************************/
  512. lottery_winner()
  513. {
  514. long tickets=0;
  515. int  n=0;
  516. long z=0;
  517. long winner=0;
  518. char lottery_name[30];
  519. char ostring[80];
  520. char string[80];
  521. FILE *fp;
  522.  
  523. if (check_file("SPCEMP:LOTTERY.USER")==TRUE)
  524.   {
  525.    fp=fopen("SPCEMP:LOTTERY.USER","r");
  526.    while(feof(fp)==FALSE)
  527.     {
  528.      fgets(string,60,fp);
  529.      sscanf(string,"%s %d",&player[epn].player,&n);
  530.      tickets=tickets+n;
  531.      n=0;
  532.     }
  533.    fclose(fp);
  534.   }
  535. if(tickets==0)
  536.   printf("Nobody has played lottery... No winner.\n");
  537.  else
  538.   {
  539.    winner=rnd(tickets);
  540.    printf("Winner is ticket no. %d. ",winner);
  541.    z=tickets;
  542.    n=0;
  543.    fp=fopen("SPCEMP:LOTTERY.USER","r");
  544.    while(z>0)
  545.     {
  546.      fgets(string,60,fp);
  547.      sscanf(string,"%s %d",&player[epn].player,&n);
  548.      z=z-n;
  549.      n=0;
  550.     }
  551.    fclose(fp);
  552.    printf("This ticket belongs to %s.\nThis player wins %d credits.\n",player[epn].player,(tickets*1000));
  553.    get_datas(epn);
  554.    player[epn].acredits=player[epn].acredits+((tickets*2000)+1000000);
  555.    put_datas(epn);
  556.    sprintf(string,"%s wins %d credits at the lottery.",player[epn].player,((tickets*2000)+1000000));
  557.    optlog(string,"SPCEMP:NEWS.TXT");
  558.    sprintf(string,"YOU win %d credits at the lottery.",((tickets*2000)+1000000));
  559.    sprintf(ostring,"SPCEMP_PLAYERS:MSG_%s.TXT",player[epn].player);
  560.    optlog(string,ostring);
  561.   }
  562. }
  563.  
  564. /*****************************************************************/
  565. /*Lottery maintenance                         */
  566. /*****************************************************************/
  567. lottery_maint()
  568. {
  569. int lottery_count=0;
  570. char string[80];
  571. FILE *fp;
  572.  
  573. if (check_file("SPCEMP:LOTTERY.DAT")==TRUE)
  574.   {
  575.    fp=fopen("SPCEMP:LOTTERY.DAT","r");
  576.      fgets(string,60,fp);
  577.      sscanf(string,"%d",&lottery_count);
  578.    fclose(fp);
  579.   }
  580. lottery_count=lottery_count+1;
  581. if(lottery_count==lottery_turn)
  582.  {
  583.   /* Take a Winner */
  584.   printf("Looking for a lottery winner.\n");
  585.   lottery_winner();
  586.   if(check_file("SPCEMP:LOTTERY.USER")==TRUE)
  587.     delete_file("SPCEMP:LOTTERY.USER");
  588.   lottery_count=0;
  589.  }
  590. if(check_file("SPCEMP:LOTTERY.DAT")==TRUE)
  591.   delete_file("SPCEMP:LOTTERY.DAT");
  592. fp=fopen("SPCEMP:LOTTERY.DAT","w");
  593.   fprintf(fp,"%d",lottery_count);
  594. fclose(fp);
  595. }
  596.  
  597. /*****************************************************************/
  598. /*Load and check for lords                     */
  599. /*****************************************************************/
  600. check_lord()
  601. {
  602. char last_date[12];
  603. char string[80];
  604. FILE *fp;
  605.  
  606.  if (check_file("SPCEMP:EMPIRE.DAT")==TRUE)
  607.   {
  608.    fp=fopen("SPCEMP:EMPIRE.DAT","r");
  609.      fgets(string,60,fp);
  610.      sscanf(string,"%s",&last_date);
  611.      fgets(string,60,fp);
  612.      sscanf(string,"%d",&lord_count);
  613.      fgets(string,60,fp);
  614.      sscanf(string,"%d",&lord_days);
  615.      fgets(string,80,fp);
  616.      sscanf(string,"%s",&lord_name);
  617.    fclose(fp);
  618.    if((lord_count==1)&&(lord_days==uridium_turn))
  619.      win_uridium();
  620.    if((lord_count==1)&&(lord_days>0))
  621.      if(lord_days==1)
  622.        printf("\n%s is sitting at the uridium throne for his first day.\n",lord_name);
  623.       else
  624.        printf("\n%s is sitting at the uridium throne for his %d. day.\n",lord_name,lord_days);
  625.    if(lord_count>1)
  626.      printf("\nThere are %d lords fighting for the uridium throne.\n",lord_count);
  627.  
  628.   }
  629. }
  630. /*****************************************************************/
  631. /*Daily maintenance                         */
  632. /*****************************************************************/
  633. daily_maint()
  634. {
  635. int run_daily=0;
  636. char last_date[12];
  637. char today_date[12];
  638. char string[80];
  639. FILE *fp;
  640.  
  641. if (check_file("SPCEMP:EMPIRE.DAT")==FALSE)
  642.   run_daily=TRUE;
  643.  else
  644.   {
  645.    fp=fopen("SPCEMP:EMPIRE.DAT","r");
  646.      fgets(string,60,fp);
  647.      sscanf(string,"%s",&last_date);
  648.      fgets(string,60,fp);
  649.      sscanf(string,"%d",&lord_count);
  650.      fgets(string,60,fp);
  651.      sscanf(string,"%d",&lord_days);
  652.      fgets(string,60,fp);
  653.      sscanf(string,"%s",&lord_name);
  654.    fclose(fp);
  655.    sscanf(date,"%s",&today_date);
  656.    if(strcmp(last_date,today_date)!=0)
  657.      run_daily=TRUE;
  658.   }
  659. if (run_daily==TRUE)
  660.  {
  661.   printf("\nYou are the first player today. Please wait until daily maintenance finished.\n");
  662.   if(check_file("SPCEMP:YESTERDAY.TXT")==TRUE)
  663.     delete_file("SPCEMP:YESTERDAY.TXT");
  664.   if(check_file("SPCEMP:NEWS.TXT")==TRUE)
  665.     rename("SPCEMP:NEWS.TXT","SPCEMP:YESTERDAY.TXT");
  666.   if(lottery_turn!=0)
  667.     lottery_maint();
  668.   if(check_file("SPCEMP:EMPIRE.DAT")==TRUE)
  669.     delete_file("SPCEMP:EMPIRE.DAT");
  670.   if(lord_count==1)
  671.     lord_days++;
  672.    else
  673.     lord_days=0;
  674.   fp=fopen("SPCEMP:EMPIRE.DAT","w");
  675.      fprintf(fp,"%s\n",date);
  676.      fprintf(fp,"%d\n",lord_count);
  677.      fprintf(fp,"%d\n",lord_days);
  678.      fprintf(fp,"%s\n",lord_name);
  679.   fclose(fp);
  680.   
  681.  }
  682. }
  683.  
  684. /*****************************************************************/
  685. misc_menu()
  686. {
  687. cls();
  688. printf("\n\nMISC-MENU\n");
  689. printf("--------------------------------------------------\n");
  690. printf(" 1) Commit Suicide\n");
  691. printf(" 2) Send Message to an other user\n");
  692. printf(" 3) Send Message to all other users\n");
  693. printf(" 4) Display News-File (today)\n");
  694. printf(" 5) Display News-File (yesterday)\n");
  695. printf(" 6) Display Private News-File\n");
  696. printf(" 7) Display own statistics \n");
  697. printf(" 8) Display Scores \n\n");
  698. printf(" 9) Game Information \n");
  699. printf("10) GameManager Options\n"); 
  700. printf("-------------------------------[0] for Mainmenu---\n\n");
  701. }
  702.  
  703. /*****************************************************************/
  704. misc_stage()
  705. {
  706. char ostring[80];
  707. long n=0;
  708. FILE *fp;
  709. int busy=FALSE;
  710. unsigned long totplanets;
  711.  
  712. totplanets=player[pn].orep+player[pn].foodp+player[pn].defensep+player[pn].tradep+player[pn].tourismp;
  713.  
  714. misc_menu();
  715.  
  716. do 
  717. {
  718.  printf("Which would you like to do ? [?] MiscMenu  ");
  719.  gets(ostring);
  720.  if(strlen(ostring)<1)
  721.     strcpy(ostring,"0");    
  722.  sscanf(ostring,"%d",&n);
  723.  if(ostring[0]=='?') 
  724.     {
  725.     misc_menu();
  726.     n=255;
  727.     }
  728.  if((n>0)&&(n<11)) 
  729.    {
  730.    if((n==1)&&(totplanets<25)&&(player[pn].played_moves>39))
  731.     {
  732.     printf("\nAre you sure ???? [y/N] ");
  733.     gets(ostring);
  734.     ostring[0]=toupper(ostring[0]);
  735.     if(ostring[0]!='Y') 
  736.         printf("");
  737.     else 
  738.         {
  739.         remove_player();
  740.         sprintf(ostring,"SPCEMP_PLAYERS:%s.sdat",player[pn].player);
  741.         delete(ostring);
  742.         news(52,"");
  743.         cls();
  744.         printf("\n\nYour Player entry has been %sEXTERMINATED%s ... \n\n",ansi(TT_BLINKING),ansi(TT_RESET));
  745.         printf("If you did not like this game, try to drink a PanGalactic-Gargelbluster (tm) !\n\n");
  746.         printf(" BYE ");
  747.                   if(check_file("SPCEMP:BUSY.STATUS")==TRUE)
  748.             delete_file("SPCEMP:BUSY.STATUS");
  749.           fp = fopen("SPCEMP:BUSY.STATUS", "w");
  750.            fprintf(fp,"%d\n",busy);
  751.            fprintf(fp,"%s\n",player[pn].player);
  752.           fclose(fp);
  753.         exit(0);
  754.         }
  755.     }
  756.    if((n==1)&&((totplanets>25)||(player[pn].played_moves<39)))
  757.     printf("Suicide is not a very nice thing and is only allowed with 24 planets or less and \nat least 40 played moves.\n");
  758.    if(n==2)
  759.     {
  760.     printf("\nWrite message to :");
  761.     if(getplayer()==TRUE)
  762.      {
  763.      printf("\n Send a message to %s : (ONLY ONE LINE PLEASE !!)\n\n",player[epn].player);
  764.      printf(" :");
  765.      gets(ostring);
  766.      ostring[70]='\0';
  767.      player_msg(11,ostring);
  768.      printf("\n Message sent to %s . \n\n",player[epn].player);
  769.      }
  770.     }
  771.    if(n==3)
  772.     {
  773.     printf("\nWrite message to all users:");
  774.      {
  775.      printf("\n Send a message : (ONLY ONE LINE PLEASE !!)\n\n");
  776.      printf(" :");
  777.      gets(ostring);
  778.      ostring[70]='\0';
  779.      news(11,ostring);
  780.      printf("\n Global Message sent. \n\n");
  781.      }
  782.     }
  783.    if(n==4)
  784.     {
  785.     display_file("SPCEMP:NEWS.TXT",MORE);
  786.     }
  787.    if(n==5)
  788.     {
  789.     display_file("SPCEMP:YESTERDAY.TXT",MORE);
  790.     }
  791.    if(n==6)
  792.     {    
  793.     sprintf(ostring,"SPCEMP_PLAYERS:MSG_%s.TXT",player[pn].player);
  794.     display_file(ostring,MORE);
  795.     }
  796.    if(n==7)
  797.     {
  798.     show_stats(pn);
  799.     }
  800.    if(n==8)
  801.     {
  802.     points(1);
  803.     display_users();
  804.     }
  805.    if(n==9)
  806.     {
  807.     cls();
  808.     printf("VMS SPACE EMPIRE V %s (%s)     (c) %sR.Sieber%s & %sN.Kuemin%s \n",version,reldate,ansi(TT_BOLD),ansi(TT_RESET),ansi(TT_BOLD),ansi(TT_RESET));
  809.     printf("----------------------------------------------------------------------\n");
  810.     printf(" Programm Information :\n\n");
  811.     printf(" # of moves of new players : %d turns\n",new_moves);
  812.     printf(" New player protection     : %d turns\n",original_prot);
  813.     printf(" Normal player (daily)     : %d turns\n\n",old_moves);
  814.     printf(" Money Transfer limit a day : %ld credits\n",max_transfer);
  815.     printf(" Interest Rates : %f, %f, %f credits\n",zins1,zins2,zins3);
  816.         if(lottery_turn!=0)
  817.       printf("\n Lottery after %d days.\n",lottery_turn);
  818.      else
  819.       printf("\n No lottery configured\n");
  820.         if(uridium_turn!=0)
  821.           {
  822.       printf("\n Win a place at the uridium throne with %d credits.\n",uridium_limit);
  823.       printf(" Stay ALONE for %d days to win the game.\n",uridium_turn);
  824.           }
  825.      else
  826.       printf("\n No uridium throne configured\n\n");
  827.         printf("\n Program-Mode : ");
  828.         if(multiuser==TRUE)
  829.           printf("Multi-User");
  830.          else
  831.           if(multiuser==FALSE)
  832.             printf("Single-User");
  833.            else
  834.             printf("unknown (%d)",multiuser);
  835.         printf("\n");
  836.     printf(" SuperSpace Empire (c)'93 by R.Sieber and N. Kuemin (it's SHAREWARE)\n");
  837.     printf("----------------------------------------------------------------------\n\n");
  838.     }
  839.    if(n==10)
  840.     {
  841.     printf("ENTER CODE :");
  842.     gets(ostring);
  843.     if(strlen(ostring)<1)
  844.         strcpy(ostring,"0");    
  845.     sscanf(ostring,"%d",&n);
  846.     if (n==supervisor)
  847.         game_mgr();
  848.     }
  849.    }
  850. } while (n!=0);
  851.  
  852. printf("\n");
  853. }
  854.  
  855. ----> END OF PART 5 <----
  856. -- 
  857.       Internet: Dr_who@pegasus.ch         __
  858.       Phone   : ++41-71-71 70 42         ///
  859.       FAX     : ++41-71-71 27 87    __  ///    "I'M THE DOCTORE BECAUSE 
  860.                                     \\\///      IT'S FUN FUN FUN ! "
  861.      BBS Phone: ++41-71-71 55 77     \XX/       - TOM BAKER 
  862.       X.25    : +228 4752 1 2574        
  863.