annotate linda.c @ 84:0c533df35784

*** empty log message ***
author gongo
date Thu, 09 Nov 2006 23:51:13 +0000
parents 22821fc0dddb
children 757d4e468a2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
1 /*
17
6910aeb52843 *** empty log message ***
gongo
parents: 0
diff changeset
2 * $Id$
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
3 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
4 #include <stdio.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
5 #include <stdlib.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
6 #include <math.h>
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
7 #include <arpa/inet.h>
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
8 #include <libps2.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
9 #include <ps2util.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
10
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
11 #include "car.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
12 #include "game.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
13 #include "lindaapi.h"
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
14 #include "linda.h"
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
15
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
16 extern void carNode_append(CarPtr);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
17 extern FILE *main_fp;
43
a1908b83f8fa *** empty log message ***
gongo
parents: 17
diff changeset
18 static int my_id;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
19 static CarPtr linda_carlist[CLIENT_MAX+1];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
20 static int linda_seq[CLIENT_MAX+1];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
21
61
39162caa4587 *** empty log message ***
gongo
parents: 58
diff changeset
22 static Bool (*sche_func)(int);
39162caa4587 *** empty log message ***
gongo
parents: 58
diff changeset
23
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
24 static void
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
25 set_header(unsigned int data, char *pkt, int offset)
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
26 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
27 int *ipkt;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
28 int ndata = htonl(data);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
29
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
30 ipkt = (int*)pkt;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
31 ipkt[offset/4] = ndata;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
32 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
33
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
34 static unsigned int
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
35 get_header(char *pkt, int offset)
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
36 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
37 int *ipkt;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
38 int data;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
39 unsigned int header;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
40
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
41 ipkt = (int *)pkt;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
42 data = ipkt[offset/4];
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
43 header = (unsigned int)ntohl(data);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
45 return header;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
46 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
47
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
48 static char*
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
49 make_packet(unsigned int mode, unsigned int carid,
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
50 unsigned int courseid, char *data)
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
51 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
52 char *packet;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
53 unsigned int len = 0;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
54
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
55 if (data) len += sizeof(FMATRIX);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
56
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
57 packet = (char*)malloc(PKT_HEADER_SIZE+len);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
58
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
59 set_header(mode, packet, PKT_MODE_OFFSET);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
60 set_header(carid, packet, PKT_CARID_OFFSET);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
61 set_header(courseid, packet, PKT_COURSEID_OFFSET);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
62
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
63 if (data)
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
64 memcpy(packet+PKT_DATA_OFFSET, data, len);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
65
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
66 return packet;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
67 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
68
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
69
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
70 static void
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
71 send_packet(unsigned int dest, unsigned int mode, unsigned int car,
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
72 unsigned int course, char *data)
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
73 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
74 char *pkt;
83
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
75 //char *reply;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
76 int len = PKT_HEADER_SIZE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
77
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
78 if (data) len += sizeof(FMATRIX);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
79
78
53a0a1124a63 *** empty log message ***
gongo
parents: 77
diff changeset
80 //reply = psx_reply(linda_seq[dest])
83
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
81 /*
80
3ab2b0980fba *** empty log message ***
gongo
parents: 79
diff changeset
82 if (linda_seq[dest] == 0) {
3ab2b0980fba *** empty log message ***
gongo
parents: 79
diff changeset
83 pkt = make_packet(mode, car, course, data);
3ab2b0980fba *** empty log message ***
gongo
parents: 79
diff changeset
84 psx_out(dest, pkt, len);
3ab2b0980fba *** empty log message ***
gongo
parents: 79
diff changeset
85 free(pkt);
82
b449f5b7cfd2 *** empty log message ***
gongo
parents: 81
diff changeset
86 } else if (reply = psx_reply(linda_seq[dest])) {
77
49bc5851acb9 *** empty log message ***
gongo
parents: 76
diff changeset
87 pkt = make_packet(mode, car, course, data);
49bc5851acb9 *** empty log message ***
gongo
parents: 76
diff changeset
88 psx_out(dest, pkt, len);
49bc5851acb9 *** empty log message ***
gongo
parents: 76
diff changeset
89 free(pkt);
49bc5851acb9 *** empty log message ***
gongo
parents: 76
diff changeset
90 psx_free(reply);
83
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
91 }
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
92 */
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
93 pkt = make_packet(mode, car, course, data);
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
94 psx_out(dest, pkt, len);
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
95 free(pkt);
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
96 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
97
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
98 static void
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
99 get_packet(int id, int *flg, int *mode, int *car, int *course, char *data)
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
100 {
47
d7e0a5c33540 *** empty log message ***
gongo
parents: 46
diff changeset
101 char *reply = NULL;
d7e0a5c33540 *** empty log message ***
gongo
parents: 46
diff changeset
102 char *pkt = NULL;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
103
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
104 reply = psx_reply(linda_seq[id]);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
105 if (reply) {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
106 pkt = reply+LINDA_HEADER_SIZE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
107
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
108 if (flg) *flg = 1;
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
109 if (mode) *mode = get_header(pkt, PKT_MODE_OFFSET);
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
110 if (car) *car = get_header(pkt, PKT_CARID_OFFSET);
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
111 if (course) *course = get_header(pkt, PKT_COURSEID_OFFSET);
56
d578f3f3b0a6 *** empty log message ***
gongo
parents: 55
diff changeset
112 if (data)
d578f3f3b0a6 *** empty log message ***
gongo
parents: 55
diff changeset
113 memcpy(data, pkt+PKT_DATA_OFFSET, sizeof(FMATRIX));
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
114 psx_free(reply);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
115 linda_seq[id] = psx_rd(id);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
116 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
117 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
118
84
0c533df35784 *** empty log message ***
gongo
parents: 83
diff changeset
119 static void
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
120 linda_set_schedule(void *func, int mode)
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
121 {
83
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
122 int id = game.play_id;
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
123
84
0c533df35784 *** empty log message ***
gongo
parents: 83
diff changeset
124 linda_seq[id] = psx_in(id);
0c533df35784 *** empty log message ***
gongo
parents: 83
diff changeset
125 sche_func = func;
0c533df35784 *** empty log message ***
gongo
parents: 83
diff changeset
126 send_packet(id, mode, game.car_id, game.course_id, NULL);
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
127 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
128
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
129 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
130 linda_sche_wait0(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
131 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
132 int i, flg=0;
81
8016a4ad065b *** empty log message ***
gongo
parents: 80
diff changeset
133 int mode = 0;
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
134 int id = game.play_id;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
135 int connect = 1; // 接続済みユーザ数
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
136
47
d7e0a5c33540 *** empty log message ***
gongo
parents: 46
diff changeset
137 for (i=1; i<=CLIENT_MAX; i++) {
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
138 if (i == id) continue;
81
8016a4ad065b *** empty log message ***
gongo
parents: 80
diff changeset
139 get_packet(i, &flg, &mode, NULL, NULL, NULL);
82
b449f5b7cfd2 *** empty log message ***
gongo
parents: 81
diff changeset
140 if (flg == 1 && mode == MODE_WAIT) {
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
141 connect++;
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
142 flg = 0;
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
143 }
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
144 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
145
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
146 if (p == 1 && connect == CLIENT_MAX) {
84
0c533df35784 *** empty log message ***
gongo
parents: 83
diff changeset
147 linda_set_schedule(linda_sche_wait_ready0, MODE_WAIT_READY);
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
148 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
149 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
150 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
151
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
152 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
153
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
154 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
155 linda_sche_wait1(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
156 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
157 int mode;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
158
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
159 get_packet(PLAYER_1P, NULL, &mode, NULL, NULL, NULL);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
160
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
161 if (mode == MODE_WAIT_READY) {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
162 linda_set_schedule(linda_sche_wait_ready1, MODE_WAIT_READY);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
163 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
164 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
165 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
166 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
167 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
168
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
169 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
170 linda_sche_wait_ready0(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
171 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
172 int i, flg, mode;
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
173 int id = game.play_id;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
174 int connect = 1;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
175
49
30fe49501a99 *** empty log message ***
gongo
parents: 48
diff changeset
176 for (i=1; i<=CLIENT_MAX; i++) {
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
177 if (i == id) continue;
50
a333d360ea6f *** empty log message ***
gongo
parents: 49
diff changeset
178 get_packet(i, &flg, &mode, NULL, NULL, NULL);
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
179 if (i == id) {
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
180 flg = 0;
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
181 continue;
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
182 }
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
183 if (flg == 1 && mode == MODE_WAIT_READY) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
184 connect++;
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
185 flg = 0;
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
186 }
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
187 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
188
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
189 if (p == 1 && connect == CLIENT_MAX) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
190 linda_set_schedule(linda_sche_opening0, MODE_OPENING);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
191 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
192 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
193 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
194 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
195
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
196 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
197
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
198 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
199 linda_sche_wait_ready1(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
200 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
201 int mode;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
202
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
203 get_packet(PLAYER_1P, NULL, &mode, NULL, NULL, NULL);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
204
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
205 if (mode == MODE_OPENING) {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
206 linda_set_schedule(linda_sche_opening1, MODE_OPENING);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
207 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
208 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
209 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
210 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
211 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
212
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
213 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
214 linda_sche_opening0(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
215 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
216 int i, flg, mode;
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
217 int id = game.play_id;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
218 int connect = 1;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
219
49
30fe49501a99 *** empty log message ***
gongo
parents: 48
diff changeset
220 for (i=1; i<=CLIENT_MAX; i++) {
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
221 if (i == id) continue;
50
a333d360ea6f *** empty log message ***
gongo
parents: 49
diff changeset
222 get_packet(i, &flg, &mode, NULL, NULL, NULL);
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
223 if (flg == 1 && mode == MODE_OPENING) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
224 connect++;
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
225 flg = 0;
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
226 }
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
227 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
228
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
229 if (p == 1 && connect == CLIENT_MAX) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
230 linda_set_schedule(linda_sche_select_car0, MODE_SELECT_CAR);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
231 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
232 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
233 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
234 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
235 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
236
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
237 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
238 linda_sche_opening1(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
239 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
240 int mode;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
241
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
242 get_packet(PLAYER_1P, NULL, &mode, NULL, NULL, NULL);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
243
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
244 if (mode == MODE_SELECT_CAR) {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
245 linda_set_schedule(linda_sche_select_car1, MODE_SELECT_CAR);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
246 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
247 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
248 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
249 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
250 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
251
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
252 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
253 linda_sche_select_car0(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
254 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
255 int i, flg, mode;
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
256 int id = game.play_id;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
257 int connect = 1;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
258
49
30fe49501a99 *** empty log message ***
gongo
parents: 48
diff changeset
259 for (i=1; i<=CLIENT_MAX; i++) {
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
260 if (i == id) continue;
50
a333d360ea6f *** empty log message ***
gongo
parents: 49
diff changeset
261 get_packet(i, &flg, &mode, NULL, NULL, NULL);
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
262 if (flg == 1 && mode == MODE_SELECT_CAR) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
263 connect++;
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
264 flg = 0;
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
265 }
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
266 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
267
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
268 if (p == 1 && connect == CLIENT_MAX) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
269 linda_set_schedule(linda_sche_select_course0, MODE_SELECT_COURSE);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
270 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
271 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
272 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
273 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
274 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
275
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
276 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
277 linda_sche_select_car1(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
278 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
279 int mode;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
280
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
281 get_packet(PLAYER_1P, NULL, &mode, NULL, NULL, NULL);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
282
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
283 if (mode == MODE_SELECT_COURSE) {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
284 linda_set_schedule(linda_sche_select_course1, MODE_SELECT_COURSE);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
285 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
286 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
287 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
288 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
289 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
290
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
291 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
292 linda_sche_select_course0(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
293 {
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
294 int i;
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
295 int flg, mode;
50
a333d360ea6f *** empty log message ***
gongo
parents: 49
diff changeset
296 int connect = 1;
46
abadcc080667 *** empty log message ***
gongo
parents: 44
diff changeset
297 int id = game.play_id;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
298 static int course_id = 1;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
299
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
300 if (course_id != game.course_id) {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
301 course_id = game.course_id;
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
302 linda_seq[id] = psx_in(id);
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
303 send_packet(id, MODE_SELECT_COURSE, 0, course_id, NULL);
50
a333d360ea6f *** empty log message ***
gongo
parents: 49
diff changeset
304 return FALSE;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
305 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
306
49
30fe49501a99 *** empty log message ***
gongo
parents: 48
diff changeset
307 for (i=1; i<=CLIENT_MAX; i++) {
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
308 if (i == id) continue;
50
a333d360ea6f *** empty log message ***
gongo
parents: 49
diff changeset
309 get_packet(i, &flg, &mode, NULL, NULL, NULL);
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
310 if (flg == 1 && mode == MODE_SELECT_COURSE) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
311 connect++;
51
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
312 flg = 0;
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
313 }
46b8f2109d34 *** empty log message ***
gongo
parents: 50
diff changeset
314
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
315 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
316
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
317 if (p == 1 && connect == CLIENT_MAX) {
68
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
318 linda_set_schedule(linda_sche_ready0, MODE_READY);
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
319 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
320 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
321 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
322 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
323 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
324
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
325 static Bool
58
1cccf6d964b7 *** empty log message ***
gongo
parents: 56
diff changeset
326 linda_sche_select_course1(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
327 {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
328 int mode, course_id;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
329
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
330 get_packet(PLAYER_1P, NULL, &mode, NULL, &course_id, NULL);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
331
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
332 if (mode == MODE_SELECT_COURSE) {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
333 game.course_id = course_id;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
334 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
335 } else if (mode == MODE_READY) {
68
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
336 linda_set_schedule(linda_sche_ready1, MODE_READY);
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
337 return TRUE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
338 } else {
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
339 return FALSE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
340 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
341 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
342
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
343
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
344 static Bool
68
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
345 linda_sche_ready0(int p)
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
346 {
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
347 int i, flg, mode;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
348 int id = game.play_id;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
349 int connect = 1;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
350
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
351 for (i=1; i<=CLIENT_MAX; i++) {
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
352 if (i == id) continue;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
353 get_packet(i, &flg, &mode, NULL, NULL, NULL);
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
354 if (flg == 1 && mode == MODE_READY) {
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
355 connect++;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
356 flg = 0;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
357 }
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
358 }
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
359
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
360 if (p == 1 && connect == CLIENT_MAX) {
69
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
361 linda_set_schedule(linda_sche_main_init, MODE_MAIN_INIT);
68
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
362 return TRUE;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
363 } else {
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
364 return FALSE;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
365 }
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
366 }
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
367
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
368 static Bool
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
369 linda_sche_ready1(int p)
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
370 {
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
371 int mode;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
372
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
373 get_packet(PLAYER_1P, NULL, &mode, NULL, NULL, NULL);
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
374
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
375 if (mode == MODE_MAIN_INIT) {
70
9a9327a6d75d *** empty log message ***
gongo
parents: 69
diff changeset
376 linda_set_schedule(linda_sche_main_init, MODE_MAIN_INIT);
68
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
377 return TRUE;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
378 } else {
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
379 return FALSE;
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
380 }
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
381 }
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
382
c72f11630cb0 *** empty log message ***
gongo
parents: 67
diff changeset
383 static Bool
69
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
384 linda_sche_main_init(int p)
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
385 {
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
386 int i, flg, mode, car_id;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
387 int id = game.play_id;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
388 int connect = 1;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
389 CarPtr car = NULL;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
390
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
391 for (i=1; i<=CLIENT_MAX; i++) {
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
392 if (i == id) continue;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
393 get_packet(i, &flg, &mode, &car_id, NULL, NULL);
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
394
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
395 if (flg == 1 && mode == MODE_MAIN_INIT) {
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
396 if (linda_carlist[i] == NULL) {
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
397 car = car_init(car_id);
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
398 carNode_append(car);
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
399 linda_carlist[i] = car;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
400 }
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
401 connect++;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
402 flg = 0;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
403 }
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
404 }
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
405
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
406 if (p == 1 && connect == CLIENT_MAX) {
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
407 if (id == PLAYER_1P)
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
408 linda_set_schedule(linda_sche_main_ready0, MODE_MAIN_READY);
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
409 else
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
410 linda_set_schedule(linda_sche_main_ready1, MODE_MAIN_READY);
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
411 return TRUE;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
412 } else {
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
413 return FALSE;
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
414 }
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
415 }
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
416
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
417
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
418 static Bool
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
419 linda_sche_main_ready0(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
420 {
67
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
421 int i, flg, mode;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
422 int id = game.play_id;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
423 int connect = 1;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
424
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
425 for (i=1; i<=CLIENT_MAX; i++) {
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
426 if (i == id) continue;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
427 get_packet(i, &flg, &mode, NULL, NULL, NULL);
69
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
428 if (flg == 1 && mode == MODE_MAIN_READY) {
67
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
429 connect++;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
430 flg = 0;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
431 }
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
432 }
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
433
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
434 if (p == 1 && connect == CLIENT_MAX) {
74
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
435 linda_set_schedule(linda_sche_main, MODE_MAIN);
67
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
436 return TRUE;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
437 } else {
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
438 return FALSE;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
439 }
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
440 }
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
441
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
442 static Bool
69
672b16f9d28f *** empty log message ***
gongo
parents: 68
diff changeset
443 linda_sche_main_ready1(int p)
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
444 {
67
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
445 int mode;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
446
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
447 get_packet(PLAYER_1P, NULL, &mode, NULL, NULL, NULL);
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
448
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
449 if (mode == MODE_MAIN) {
74
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
450 linda_set_schedule(linda_sche_main, MODE_MAIN);
67
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
451 return TRUE;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
452 } else {
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
453 return FALSE;
74c59d9abde3 *** empty log message ***
gongo
parents: 66
diff changeset
454 }
52
c875add6256e *** empty log message ***
gongo
parents: 51
diff changeset
455 }
c875add6256e *** empty log message ***
gongo
parents: 51
diff changeset
456
c875add6256e *** empty log message ***
gongo
parents: 51
diff changeset
457 static Bool
74
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
458 linda_sche_main(int p)
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
459 {
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
460 int i, flg, mode;
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
461 int id = game.play_id;
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
462 int connect = 1;
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
463 FMATRIX po;
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
464 CarPtr mycar = game.jiki;
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
465 CarPtr enemy = NULL;
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
466
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
467 for (i=1; i<=CLIENT_MAX; i++) {
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
468 ps2_vu0_unit_matrix(po);
83
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
469 get_packet(i, &flg, &mode, NULL, NULL, (char*)po);
74
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
470
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
471 if (i == id) {
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
472 ps2_vu0_copy_matrix(po, mycar->body->transfer);
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
473 ps2_vu0_copy_vector(po[3], mycar->location);
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
474
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
475 linda_seq[i] = psx_in(i);
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
476 send_packet(i, MODE_MAIN, 0, 0, (char*)po);
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
477 } else {
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
478 enemy = linda_carlist[i];
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
479 get_packet(i, NULL, &mode, NULL, NULL, (char*)po);
83
22821fc0dddb *** empty log message ***
gongo
parents: 82
diff changeset
480 if (flg == 1 && mode == MODE_MAIN) {
74
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
481 ps2_vu0_copy_matrix(enemy->body->transfer, po);
75
89ede83e7959 *** empty log message ***
gongo
parents: 74
diff changeset
482 enemy->body->transfer[3][0] -= mycar->location[0];
89ede83e7959 *** empty log message ***
gongo
parents: 74
diff changeset
483 enemy->body->transfer[3][1] -= mycar->location[1];
89ede83e7959 *** empty log message ***
gongo
parents: 74
diff changeset
484 enemy->body->transfer[3][2] -= mycar->location[2];
74
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
485 enemy->body->transfer[3][3] = 1;
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
486 }
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
487 }
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
488 }
76
cd3457b7e098 *** empty log message ***
gongo
parents: 75
diff changeset
489 return FALSE;
74
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
490 }
ec6563ccd5f4 *** empty log message ***
gongo
parents: 73
diff changeset
491
61
39162caa4587 *** empty log message ***
gongo
parents: 58
diff changeset
492 Bool
39162caa4587 *** empty log message ***
gongo
parents: 58
diff changeset
493 linda_update(int p)
39162caa4587 *** empty log message ***
gongo
parents: 58
diff changeset
494 {
39162caa4587 *** empty log message ***
gongo
parents: 58
diff changeset
495 return sche_func(p);
39162caa4587 *** empty log message ***
gongo
parents: 58
diff changeset
496 }
39162caa4587 *** empty log message ***
gongo
parents: 58
diff changeset
497
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
498 #if 0
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
499
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
500 /*
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
501 * 位置が同じなら1を返す。
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
502 * もっと良い比較方法があるんでは...
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
503 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
504 static int
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
505 linda_jiki_compareLocation()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
506 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
507 float x,y,z;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
508 double d;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
509
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
510 if (common_state == GAME_MAIN || common_state == GAME_GOAL) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
511 x = jiki.position[3][0] - game.jiki->location[0];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
512 y = jiki.position[3][1] - game.jiki->location[1];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
513 z = jiki.position[3][2] - game.jiki->location[2];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
514 d = sqrt(x*x+y*y+z*z);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
515
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
516 if (d < 1.0) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
517 return 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
518 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
519 return 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
520 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
521 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
522 return 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
523 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
524 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
525
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
526
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
527 /*
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
528 * 自機情報が更新されていなければ
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
529 * 0を返す(psx_outしない)
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
530 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
531 static int
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
532 linda_jiki_compare()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
533 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
534 if ((jiki.car_id == game.car_id) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
535 (jiki.course_id == game.course_id) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
536 (jiki.create_flg == ((game.jiki) ? 1:0)) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
537 (jiki.state == common_state) &&
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
538 (linda_jiki_compareLocation())) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
539 return 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
540 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
541 return 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
542 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
543 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
544
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
545 static void
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
546 linda_jiki_update()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
547 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
548 int i,j;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
549
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
550
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
551 jiki.car_id = game.car_id;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
552 jiki.course_id = game.course_id;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
553 jiki.create_flg = (game.jiki) ? 1 : 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
554 jiki.state = common_state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
555
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
556 if (common_state == GAME_MAIN || common_state == GAME_GOAL) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
557 for (i=0; i<3; i++) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
558 for (j=0; j<4; j++) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
559 jiki.position[i][j]
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
560 = game.jiki->body->transfer[i][j];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
561 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
562 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
563 jiki.position[3][0] = game.jiki->location[0];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
564 jiki.position[3][1] = game.jiki->location[1];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
565 jiki.position[3][2] = game.jiki->location[2];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
566 jiki.position[3][3] = 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
567 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
568 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
569
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
570 void
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
571 linda_update()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
572 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
573 int i;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
574 int barrier = 1; // バリア同期(?)用
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
575 int connect = 1;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
576 int mode, id, flg;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
577 char* reply;
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
578 char* pkt;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
579 CarPtr car = NULL;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
580
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
581 for (i=1; i<=CLIENT_MAX; i++) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
582 reply = psx_reply(linda_seq[i]);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
583 if (reply) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
584 pkt = reply+LINDA_HEADER_SIZE;
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
585 mode = get_header(pkt, PKT_MODE_OFFSET);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
586 id = get_header(pkt, PKT_ID_OFFSET);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
587 flg = get_header(pkt, PKT_FLG_OFFSET);
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
588
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
589 if (i != game.play_id) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
590 connect++;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
591
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
592 car = linda_carlist[i];
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
593 if (common_state == GAME_MAIN && !car && p->create_flg == 1) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
594 car = car_init(p->car_id);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
595 carNode_append(car);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
596 linda_carlist[i] = car;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
597 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
598 linda_enemy_update(i, car, p);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
599 if (common_state == p->state) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
600 barrier++;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
601 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
602 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
603 psx_free(reply);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
604 linda_seq[i] = psx_rd(i);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
605 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
606 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
607
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
608 if (connect == CLIENT_MAX) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
609 if (game.state == GAME_WAIT) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
610 gFont_SetString("CONNECT OK!!", 170, 300);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
611 if (game.play_id == 1)
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
612 gFont_SetString(" PUSH START ", 170, 400);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
613 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
614
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
615 // ごちゃごちゃしてる...
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
616 // なんか無駄な処理がありそうだ
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
617 if (game.play_id == 1) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
618 // 全員のフラグ成立
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
619 if (common_state == GAME_GOAL) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
620 if (game.state == GAME_FINISH) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
621 common_state = game.state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
622 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
623 game.state = common_state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
624 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
625 } else if (barrier == CLIENT_MAX) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
626 common_state = game.state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
627 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
628 game.state = common_state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
629 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
630 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
631 if (game.state == GAME_GOAL) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
632 if (common_state != GAME_FINISH) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
633 common_state = game.state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
634 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
635 game.state = common_state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
636 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
637 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
638 game.state = common_state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
639 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
640 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
641 } else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
642 if (game.state == GAME_WAIT) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
643 gFont_SetString("WAITING...", 200, 100);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
644 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
645 game.state = common_state;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
646 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
647
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
648 if (linda_jiki_compare()) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
649 #ifdef DEBUG
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
650 // どのタイミングでoutされてるか見る
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
651 // 必要なときだけoutしないと重いですね当然だけど
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
652 //fprintf(main_fp, "psx_out() jiki\n");
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
653 #endif
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
654 linda_jiki_update();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
655 // 無理矢理
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
656 // 古いものを消すだけなんだけど
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
657 // 正しいやり方が他に有るのかな?
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
658 // 実行し続けてると最終的に激重になるので
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
659 // ここら辺に問題が有るのだろうか。
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
660 // psx_free(psx_reply(psx_in(game.play_id)));
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
661 linda_seq[my_id]=psx_in(game.play_id);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
662 psx_out(game.play_id, (char*)&jiki, sizeof(CarInfo));
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
663 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
664 }
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
665 #endif
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
666
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
667 static int
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
668 get_id()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
669 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
670 unsigned char * reply;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
671 int seq;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
672 int id;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
673
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
674 //ユーザIDが格納されているTUPLE SpaceのIDへアクセス
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
675 seq = psx_in(LINDA_ASK_ID);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
676
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
677 // IDが取得できるまでループ
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
678 while((reply = psx_reply(seq)) == 0) psx_sync_n();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
679
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
680 id = atoi(reply+LINDA_HEADER_SIZE);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
681 psx_free(reply);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
682 return id;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
683 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
684
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
685 void
43
a1908b83f8fa *** empty log message ***
gongo
parents: 17
diff changeset
686 linda_env_init()
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
687 {
43
a1908b83f8fa *** empty log message ***
gongo
parents: 17
diff changeset
688 int i;
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
689
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
690 for (i=0; i<CLIENT_MAX+1; i++) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
691 linda_carlist[i] = NULL;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
692 }
43
a1908b83f8fa *** empty log message ***
gongo
parents: 17
diff changeset
693
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
694 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
695
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
696
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
697
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
698 int
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
699 linda_init()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
700 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
701 int i;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
702
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
703 start_linda(LINDA_HOST);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
704 my_id = get_id();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
705
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
706 for (i=1; i<=CLIENT_MAX; i++) {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
707 if (i == my_id) {
44
3b71b39411b1 *** empty log message ***
gongo
parents: 43
diff changeset
708 send_packet(i, MODE_WAIT, i, 0, NULL);
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
709 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
710 linda_seq[i] = psx_rd(i);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
711 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
712 psx_sync_n();
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
713
48
21178806ad26 *** empty log message ***
gongo
parents: 47
diff changeset
714 if (my_id == PLAYER_1P) {
63
f23e36bbb060 *** empty log message ***
gongo
parents: 61
diff changeset
715 sche_func = &linda_sche_wait0;
48
21178806ad26 *** empty log message ***
gongo
parents: 47
diff changeset
716 } else {
63
f23e36bbb060 *** empty log message ***
gongo
parents: 61
diff changeset
717 sche_func = &linda_sche_wait1;
48
21178806ad26 *** empty log message ***
gongo
parents: 47
diff changeset
718 }
84
0c533df35784 *** empty log message ***
gongo
parents: 83
diff changeset
719 send_packet(game.play_id, MODE_WAIT, 1, 1, NULL);
0c533df35784 *** empty log message ***
gongo
parents: 83
diff changeset
720
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
721 return my_id;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
722 }