comparison interface.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
comparison
equal deleted inserted replaced
2:fba0b6e6cdc7 3:5a977ccbc7a9
1 /* $Id: interface.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */
2
3 /*
4 * interface.c
5 *
6 * This file will include all the interfaces between the input routines
7 * and the daemon. They should be useful for writing robots and the
8 * like
9 */
10 #include "copyright.h"
11
12 #include <stdio.h>
13 #include <math.h>
14 #include <sys/types.h>
15 #include <sys/time.h>
16 #ifndef sgi
17 #include <sys/timeb.h>
18 #endif /* sgi */
19 #include <signal.h>
20 #include "Wlib.h"
21 #include "defs.h"
22 #include "struct.h"
23 #include "data.h"
24 #include "packets.h"
25 #include "proto.h"
26
27 void
28 set_speed(speed)
29 int speed;
30 {
31 /* don't repeat useless commands [BDyess] */
32 if (me->p_desspeed != speed || me->p_speed != speed)
33 sendSpeedReq(speed);
34 me->p_desspeed = speed;
35 }
36
37 void
38 set_course(dir)
39 unsigned int dir;
40 {
41 /* don't repeat commands [BDyess] */
42 if (me->p_desdir != dir || me->p_dir != dir)
43 sendDirReq(dir);
44 me->p_desdir = dir;
45 }
46
47 void
48 shield_up()
49 {
50 if (!(me->p_flags & PFSHIELD)) {
51 sendShieldReq(1);
52 }
53 }
54
55 void
56 shield_down()
57 {
58 if (me->p_flags & PFSHIELD) {
59 sendShieldReq(0);
60 }
61 }
62
63 void
64 shield_tog()
65 {
66 if (me->p_flags & PFSHIELD) {
67 sendShieldReq(0);
68 } else {
69 sendShieldReq(1);
70 }
71 }
72
73 void
74 bomb_planet()
75 {
76 if (!(me->p_flags & PFBOMB)) {
77 sendBombReq(1);
78 }
79 }
80
81 void
82 beam_up()
83 {
84 if (!(me->p_flags & PFBEAMUP)) {
85 sendBeamReq(1); /* 1 means up... */
86 }
87 }
88
89 void
90 beam_down()
91 {
92 if (!(me->p_flags & PFBEAMDOWN)) {
93 sendBeamReq(2); /* 2 means down... */
94 }
95 }
96
97 void
98 cloak()
99 {
100 if (me->p_flags & PFCLOAK) {
101 sendCloakReq(0);
102 } else {
103 sendCloakReq(1);
104 }
105 }
106
107 int
108 mtime()
109 {
110 #if 0
111 struct timeb tm;
112
113 ftime(&tm);
114 /* mask off 16 high bits and add in milliseconds */
115 return (tm.time & 0x0000ffff) * 1000 + tm.millitm;
116 #else
117 struct timeval tv;
118
119 gettimeofday(&tv, (struct timezone *) 0);
120 return (tv.tv_sec & 0x0ffff) * 1000 + tv.tv_usec / 1000;
121 #endif
122 }