local.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* local.c -- dungeon functions which need local definition */
  2. #include "funcs.h"
  3. #ifdef __AMOS__
  4. #include <moncal.h>
  5. #endif
  6. /* This function should return TRUE_ if it's OK for people to play the
  7. * game, FALSE_ otherwise. If you have a working <time.h> library,
  8. * you can define NONBUSINESS to disallow play Monday to Friday, 9-5
  9. * (this is only checked at the start of the game, though). For more
  10. * complex control you will have to write your own version of this
  11. * function.
  12. */
  13. #ifdef NONBUSINESS
  14. #ifdef BSD4_2
  15. #include <sys/timeb.h>
  16. #else /* ! BSD4_2 */
  17. #include <time.h>
  18. #endif /* ! BSD4_2 */
  19. #endif /* NONBUSINESS */
  20. logical protected()
  21. {
  22. #ifndef NONBUSINESS
  23. return TRUE_;
  24. #else /* NONBUSINESS */
  25. time_t t;
  26. struct tm *q;
  27. (void)time(&t);
  28. q = localtime(&t);
  29. /* Return TRUE_ if it's Sunday or Saturday or before 9 or after 5 */
  30. if (q->tm_wday == 0 || q->tm_wday == 6)
  31. return TRUE_;
  32. else if (q->tm_hour < 9 || q->tm_hour >= 17)
  33. return TRUE_;
  34. else
  35. return FALSE_;
  36. #endif /* NONBUSINESS */
  37. }
  38. #ifdef ALLOW_GDT
  39. /* This function should return TRUE_ if the user is allowed to invoke the
  40. * game debugging tool by typing "gdt". This isn't very useful without
  41. * the source code, and it's mainly for people trying to debug the game.
  42. * You can define WIZARDID to specify a user id on a UNIX system. On a
  43. * non AMOS, non unix system this function will have to be changed if
  44. * you want to use gdt.
  45. */
  46. #ifndef WIZARDID
  47. #define WIZARDID (0)
  48. #endif
  49. logical wizard()
  50. {
  51. #ifdef __AMOS__
  52. if (jobidx()->jobusr == 0x102)
  53. return TRUE_;
  54. #else
  55. #ifdef unix
  56. if (getuid() == 0 || getuid() == WIZARDID)
  57. return TRUE_;
  58. #endif
  59. #endif
  60. return TRUE_;
  61. }
  62. #endif