home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume2 / dungeon / part07 / rtim.c < prev    next >
C/C++ Source or Header  |  1987-09-01  |  906b  |  62 lines

  1. /*
  2.  * Interface routines for dungeon.
  3.  * These routines are for functions expected by the game
  4.  * that are not available in the Unix/f77 library.
  5.  */
  6.  
  7. /* routine to get time in hours minutes and seconds */
  8.  
  9. #include <sys/types.h>
  10. #include <sys/timeb.h>
  11. /* for V7 this should be <time.h> */
  12. #include <sys/time.h>
  13.  
  14.  
  15. long time();
  16. struct tm *localtime();
  17. struct tm *tmptr;
  18. long timebuf;
  19.  
  20. itime_(hrptr,minptr,secptr)
  21.  
  22. int *hrptr,*minptr,*secptr;
  23. {
  24.  
  25.     time(&timebuf);
  26.     tmptr = localtime(&timebuf);
  27.     
  28.     *hrptr  = tmptr->tm_hour;
  29.     *minptr = tmptr->tm_min;
  30.     *secptr = tmptr->tm_sec;
  31.  
  32.     return;
  33. }
  34.  
  35. /* random number initializer */
  36. inirnd_(seedptr)
  37.  
  38. int *seedptr;
  39. {
  40. int seed;
  41.  
  42.     seed = *seedptr;
  43.     srand(seed);
  44.     return;
  45. }
  46.  
  47. /*  random number generator */
  48. rnd_(maxval)
  49.  
  50. int *maxval;
  51. {
  52. /* note: returned random number ranges from 0 to maxval */
  53.  
  54. int rndval;
  55.  
  56.     rndval = rand();
  57.  
  58.     rndval = rndval % *maxval;
  59.  
  60.     return(rndval);
  61. }
  62.