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