annotate linda.c @ 74:ec6563ccd5f4

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