changeset 69:672b16f9d28f

*** empty log message ***
author gongo
date Thu, 09 Nov 2006 04:24:00 +0000
parents c72f11630cb0
children 9a9327a6d75d
files linda.c linda.h
diffstat 2 files changed, 53 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/linda.c	Thu Nov 09 03:37:24 2006 +0000
+++ b/linda.c	Thu Nov 09 04:24:00 2006 +0000
@@ -108,7 +108,7 @@
 {
     linda_seq[game.play_id] = psx_in(game.play_id);
     sche_func = func;
-    send_packet(game.play_id, mode, 1, 1, NULL);
+    send_packet(game.play_id, mode, game.car_id, game.course_id, NULL);
 }
 
 static Bool
@@ -343,12 +343,11 @@
     }
 
     if (p == 1 && connect == CLIENT_MAX) {
-	linda_set_schedule(linda_sche_main_init0, MODE_MAIN_INIT);
+	linda_set_schedule(linda_sche_main_init, MODE_MAIN_INIT);
 	return TRUE;
     } else {
 	return FALSE;
     }
-    return TRUE;
 }
 
 static Bool
@@ -359,7 +358,7 @@
     get_packet(PLAYER_1P, NULL, &mode, NULL, NULL, NULL);
 
     if (mode == MODE_MAIN_INIT) {
-	linda_set_schedule(linda_sche_main_init1, MODE_MAIN_INIT);
+	linda_set_schedule(linda_sche_main_init0, MODE_MAIN_INIT);
 	return TRUE;
     } else {
 	return FALSE;
@@ -367,7 +366,42 @@
 }
 
 static Bool
-linda_sche_main_init0(int p)
+linda_sche_main_init(int p)
+{
+    int i, flg, mode, car_id;
+    int id = game.play_id;
+    int connect = 1;
+    CarPtr car = NULL;
+
+    for (i=1; i<=CLIENT_MAX; i++) {
+	if (i == id) continue;
+	get_packet(i, &flg, &mode, &car_id, NULL, NULL);
+
+	if (flg == 1 && mode == MODE_MAIN_INIT) {
+	    if (linda_carlist[i] == NULL) {
+		car = car_init(car_id);
+		carNode_append(car);
+		linda_carlist[i] = car;
+	    }
+	    connect++;
+	    flg = 0;
+	}
+    }
+
+    if (p == 1 && connect == CLIENT_MAX) {
+	if (id == PLAYER_1P)
+	    linda_set_schedule(linda_sche_main_ready0, MODE_MAIN_READY);
+	else
+	    linda_set_schedule(linda_sche_main_ready1, MODE_MAIN_READY);
+	return TRUE;
+    } else {
+	return FALSE;
+    }
+}
+
+
+static Bool
+linda_sche_main_ready0(int p)
 {
     int i, flg, mode;
     int id = game.play_id;
@@ -376,7 +410,7 @@
     for (i=1; i<=CLIENT_MAX; i++) {
 	if (i == id) continue;
 	get_packet(i, &flg, &mode, NULL, NULL, NULL);
-	if (flg == 1 && mode == MODE_MAIN) {
+	if (flg == 1 && mode == MODE_MAIN_READY) {
 	    connect++;
 	    flg = 0;
 	}
@@ -388,11 +422,10 @@
     } else {
 	return FALSE;
     }
-    return TRUE;
 }
 
 static Bool
-linda_sche_main_init1(int p)
+linda_sche_main_ready1(int p)
 {
     int mode;
 
@@ -410,16 +443,15 @@
 linda_sche_main0(int p)
 {
     FMATRIX data;
-    static int i=0;
 
     ps2_vu0_unit_matrix(data);
     ps2_vu0_copy_matrix(data, game.jiki->body->transfer);
     ps2_vu0_copy_vector(data[3], game.jiki->location);
 	
     linda_seq[game.play_id] = psx_in(game.play_id);
-    send_packet(game.play_id, MODE_MAIN, 1, 1, (char*)data);
+    send_packet(game.play_id, MODE_MAIN, 0, 0, (char*)data);
 
-    return FALSE;
+   return FALSE;
 }
 
 static Bool
--- a/linda.h	Thu Nov 09 03:37:24 2006 +0000
+++ b/linda.h	Thu Nov 09 04:24:00 2006 +0000
@@ -32,11 +32,12 @@
 #define MODE_SELECT_COURSE    5
 #define MODE_READY            6
 #define MODE_MAIN_INIT        7
-#define MODE_MAIN             8
-#define MODE_MAIN_PAUSE       9
-#define MODE_MAIN_GOAL       10
-#define MODE_MAIN_FINISH     11
-#define MODE_FINISH          12
+#define MODE_MAIN_READY       8
+#define MODE_MAIN             9
+#define MODE_MAIN_PAUSE      10
+#define MODE_MAIN_GOAL       11
+#define MODE_MAIN_FINISH     12
+#define MODE_FINISH          13
 
 
 #define PLAYER_1P 1
@@ -53,7 +54,9 @@
 static Bool linda_sche_select_course1(int);
 static Bool linda_sche_ready0(int);
 static Bool linda_sche_ready1(int);
-static Bool linda_sche_main_init0(int);
-static Bool linda_sche_main_init1(int);
+static Bool linda_sche_main_init(int);
+static Bool linda_sche_main_init(int);
+static Bool linda_sche_main_ready0(int);
+static Bool linda_sche_main_ready1(int);
 static Bool linda_sche_main0(int);
 static Bool linda_sche_main1(int);