changeset 83:22821fc0dddb

*** empty log message ***
author gongo
date Thu, 09 Nov 2006 19:08:22 +0000
parents b449f5b7cfd2
children 0c533df35784
files ChangeLog linda.c
diffstat 2 files changed, 39 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Nov 09 08:50:31 2006 +0000
+++ b/ChangeLog	Thu Nov 09 19:08:22 2006 +0000
@@ -1,3 +1,15 @@
+2006-11-10  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
+
+	* linda.c:linda_set_schedule
+	psx_inとpsx_outを同時にしてはいけないらしいので
+	最初にinをして、データが無くなったのを確認できたら
+	send_packetを行う。ただ、send_packetをしない場合は
+	scheduleも変わらないようにしないといけないので
+	返り値で判断しようかと考え中だが
+	Boolでやって以下書いたコード全部if文書くのは
+	めんどくさいよ〜。でもやらないとだが。でも眠い(現在28時
+	
+
 2006-11-09    <j03056@mammaaiuto.cr.ie.u-ryukyu.ac.jp>
 
 	* xml.c
--- a/linda.c	Thu Nov 09 08:50:31 2006 +0000
+++ b/linda.c	Thu Nov 09 19:08:22 2006 +0000
@@ -72,12 +72,13 @@
 	    unsigned int course,  char *data)
 {
     char *pkt;
-    char *reply;
+    //char *reply;
     int len = PKT_HEADER_SIZE;
 
     if (data) len += sizeof(FMATRIX);
 
     //reply = psx_reply(linda_seq[dest])
+    /*
     if (linda_seq[dest] == 0) {
 	pkt = make_packet(mode, car, course, data);
 	psx_out(dest, pkt, len);
@@ -87,7 +88,11 @@
 	psx_out(dest, pkt, len);
 	free(pkt);
 	psx_free(reply);
-    }
+	}
+    */
+    pkt = make_packet(mode, car, course, data);
+    psx_out(dest, pkt, len);
+    free(pkt);
 }
 
 static void
@@ -111,12 +116,22 @@
     }    
 }
 
-static void
+static Bool
 linda_set_schedule(void *func, int mode)
 {
-    //linda_seq[game.play_id] = psx_in(game.play_id);
-    sche_func = func;
-    send_packet(game.play_id, mode, game.car_id, game.course_id, NULL);
+    char *reply = NULL;
+    int id = game.play_id;
+
+    reply = psx_reply(linda_seq[id]);
+    if (reply) {
+	linda_seq[id] = psx_in(id);
+	psx_free(reply);
+	return FALSE;
+    } else {
+	sche_func = func;
+	send_packet(id, mode, game.car_id, game.course_id, NULL);
+	return TRUE;
+    }
 }
 
 static Bool
@@ -137,8 +152,10 @@
     }
 
     if (p == 1 && connect == CLIENT_MAX) {
-	linda_set_schedule(linda_sche_wait_ready0, MODE_WAIT_READY);
-	return TRUE;
+	if (linda_set_schedule(linda_sche_wait_ready0, MODE_WAIT_READY) == TRUE)
+	    return TRUE;
+	else
+	    return FALSE;
     } else {
 	return FALSE;
     }
@@ -460,7 +477,7 @@
 
     for (i=1; i<=CLIENT_MAX; i++) {
 	ps2_vu0_unit_matrix(po);
-	get_packet(i, NULL, &mode, NULL, NULL, (char*)po);
+	get_packet(i, &flg, &mode, NULL, NULL, (char*)po);
 
 	if (i == id) {
 	    ps2_vu0_copy_matrix(po, mycar->body->transfer);
@@ -471,7 +488,7 @@
 	} else {
 	    enemy = linda_carlist[i];
 	    get_packet(i, NULL, &mode, NULL, NULL, (char*)po);	    
-	    if (mode == MODE_MAIN) {
+	    if (flg == 1 && mode == MODE_MAIN) {
 		ps2_vu0_copy_matrix(enemy->body->transfer, po);
 		enemy->body->transfer[3][0] -= mycar->location[0];
 		enemy->body->transfer[3][1] -= mycar->location[1];