annotate Renderer/Test/network.cc @ 1846:a0cb52163e57 draft

simplify GPU flip. Do not use output argments in flip. flip requires different kernel.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 21 Dec 2013 08:38:13 +0900
parents 16c795222988
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <string.h>
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <fcntl.h>
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <sys/types.h>
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include <sys/mman.h>
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include <sys/stat.h>
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include <unistd.h>
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "SceneGraphRoot.h"
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "lindaapi.h"
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "network.h"
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "network_game.pb.h"
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #define GET_SERIAL_ID 65535
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 int NetworkGame::last_player_id = 0;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 Viewer *NetworkGame::sgroot;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 linda_t NetworkGame::linda_addr = { "localhost", 10000 };
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 int NetworkGame::linda;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 int NetworkGame::serial_id;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 int NetworkGame::width;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 int NetworkGame::start_x;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 char *NetworkGame::xml_file_name;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
1153
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
25 const char *usr_help_str = "Usage: ./network [-linda LINDA_SERVER_NAME [-port PORT_NUM]] -xml XML_OBJECT_FILE_NAME\na";
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 void TMend(TaskManager *manager);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 extern void task_initialize();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 extern int init(TaskManager *manager, int argc, char *argv[]);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 extern Application *
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 application() {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 return new NetworkGame();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
1011
3a648f8f5d77 warning fix
tkaito
parents: 975
diff changeset
35 /*
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 static void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 null_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 }
1011
3a648f8f5d77 warning fix
tkaito
parents: 975
diff changeset
40 */
3a648f8f5d77 warning fix
tkaito
parents: 975
diff changeset
41
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 static void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 null_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 NetworkGame::update_last_player_id() {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 last_player_id++;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 if (last_player_id == serial_id)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 last_player_id++;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 NetworkGame::set_position(SceneGraphPtr node, unsigned char *reply) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 network_game::Position *pos = new network_game::Position();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 pos->ParseFromArray(reply + LINDA_HEADER_SIZE, psx_get_datalength(reply));
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 node->xyz[0] = pos->x();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 node->xyz[1] = pos->y();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 node->angle[0] = pos->angle_x();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 node->angle[1] = pos->angle_y();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 delete pos;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 static void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 update_position_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 // LindaServerから座標データを取得してオブジェクトに反映させる。
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 if (!node->resend_flag || node->seq_rd != node->seq) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 unsigned char *reply_rd = psx_reply(node->seq_rd);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 if (reply_rd != NULL) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 NetworkGame::set_position(node, reply_rd);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 psx_free(reply_rd);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 return;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 unsigned char *reply = psx_reply(node->seq);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 if (reply != NULL) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 // NetworkGame::set_position(node, reply);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 psx_free(reply);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 node->seq = psx_wait_rd(NetworkGame::linda, node->id * 10 + 1);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 node->resend_flag = true;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 } else if (node->resend_flag) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 node->seq_rd = psx_rd(NetworkGame::linda, node->id * 10 + 1);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 node->resend_flag = false;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 SceneGraphPtr
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 create_sg(Viewer *viewer, SceneGraphPtr par, unsigned char *data, int len, int serial_id)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 SceneGraphPtr child = viewer->sgroot->createSceneGraph();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 viewer->sgroot->createFromXMLmemory(viewer->sgroot->tmanager, child, (char *)data, len);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 child->set_move_collision(update_position_move, null_collision);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 child->id = serial_id;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 child->seq = psx_wait_rd(NetworkGame::linda, serial_id * 10 + 1);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 child->seq_rd = psx_rd(NetworkGame::linda, serial_id * 10 + 1);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 child->resend_flag = false;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 par->addChild(child);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 return child;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 static void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 check_new_player_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 unsigned char *reply_rd = psx_reply(node->seq_rd);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 if (reply_rd != NULL) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 unsigned char *xml_data = reply_rd + LINDA_HEADER_SIZE;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 int xml_len = psx_get_datalength(reply_rd);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 create_sg(NetworkGame::sgroot, node, xml_data, xml_len, NetworkGame::last_player_id);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 psx_free(reply_rd);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 NetworkGame::update_last_player_id();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 int tuple_id = NetworkGame::last_player_id * 10;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 node->seq_rd = psx_rd(NetworkGame::linda, tuple_id);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 // printf("rd id: %d\n", NetworkGame::last_player_id);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 void *
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 file_map(const char *filename, int *size) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 int fd;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 void *addr;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 struct stat sb;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 if ((fd = open(filename, O_RDONLY)) == -1) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 fprintf(stderr, "Can't open %s\n", filename);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 perror(NULL);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 if (fstat(fd, &sb) == -1) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 fprintf(stderr, "Can't fstat %s\n", filename);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 perror(NULL);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 *size = sb.st_size;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 addr = mmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 if (addr == MAP_FAILED) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 perror("mmap error\n");
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 exit(EXIT_FAILURE);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 close(fd);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 return addr;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 void callback_free(unsigned char *tuple, void *arg) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 psx_free(tuple);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 NetworkGame::send_position(SceneGraphPtr node) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 int pos_id = serial_id * 10 + 1;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 psx_callback_in(linda, pos_id, callback_free, NULL);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 network_game::Position *pos = new network_game::Position();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 pos->set_x(node->xyz[0]);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 pos->set_y(node->xyz[1]);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 pos->set_angle_x(node->angle[0]);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 pos->set_angle_y(node->angle[1]);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 int size = pos->ByteSize();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 unsigned char *msg = (unsigned char *) sgroot->manager->allocate(sizeof(char) * size);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 pos->SerializeToArray(msg, size); // 更新したデータを再度シリアライズ
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 delete pos;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 psx_out(linda, pos_id, msg, size);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 my_move(SceneGraphPtr node, void *sgroot_, int w, int h)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 Pad *pad = sgroot->getController();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 int flag = 0;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 if (pad->right.isHold() || pad->left.isHold()) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 if (pad->right.isHold()) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 node->xyz[0] += 5.0f;
975
c48e3866f85f player is center in camera
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 974
diff changeset
173 sgroot->camera->xyz[0] = node->xyz[0];
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 // node->angle[1] = 0.0f;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 flag = 1;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 } else if (pad->left.isHold()) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 node->xyz[0] -= 5.0f;
975
c48e3866f85f player is center in camera
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 974
diff changeset
178 sgroot->camera->xyz[0] = node->xyz[0];
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 // node->angle[1] = 180.0f;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 flag = 1;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 if (pad->down.isHold() || pad->up.isHold() ) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 if (pad->down.isHold()) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 node->xyz[1] += 5.0f;
975
c48e3866f85f player is center in camera
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 974
diff changeset
187 sgroot->camera->xyz[1] = node->xyz[1];
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 flag = 1;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 } else if (pad->up.isHold()) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 node->xyz[1] -= 5.0f;
975
c48e3866f85f player is center in camera
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 974
diff changeset
191 sgroot->camera->xyz[1] = node->xyz[1];
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 flag = 1;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 /* ここで座標を送信 */
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 if (flag || node->resend_flag) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 NetworkGame::send_position(node);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 NetworkGame::create_my_sg(Viewer *viewer, SceneGraphPtr par, int screen_w, int screen_h)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 int size;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 void *addr = file_map(xml_file_name, &size);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 SceneGraphPtr sgp = viewer->createSceneGraph();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 viewer->createFromXMLmemory(sgp, (char *)addr, size);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 sgp->set_move_collision(my_move, null_collision);
975
c48e3866f85f player is center in camera
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 974
diff changeset
210 Camera *camera = viewer->sgroot->camera;
c48e3866f85f player is center in camera
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 974
diff changeset
211 camera->xyz[0] = 0.0;
c48e3866f85f player is center in camera
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 974
diff changeset
212 camera->xyz[1] = 0.0;
c48e3866f85f player is center in camera
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 974
diff changeset
213
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 par->addChild(sgp);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 sgp->c_xyz[0] = 0.0f;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 sgp->c_xyz[1] = 0.0f;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 sgp->c_xyz[2] = 0.0f;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 int xml_id = serial_id * 10;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 psx_out(linda, xml_id, (unsigned char *)addr, size);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 int pos_id = serial_id * 10 + 1;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 network_game::Position *pos = new network_game::Position();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 pos->set_x(0.0f);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 pos->set_y(0.0f);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 pos->set_angle_x(0.0f);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 pos->set_angle_y(0.0f);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 unsigned char *msg = (unsigned char *) viewer->manager->allocate(sizeof(unsigned char *) * size);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 pos->SerializeToArray(msg, size);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 psx_out(linda, pos_id, (unsigned char *)msg, pos->ByteSize());
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 delete pos;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 sgp->seq = 0;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 sgp->resend_flag = 0;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 MainLoopPtr
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 NetworkGame::init(Viewer *sgroot, int screen_w, int screen_h)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 this->sgroot = sgroot;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 width = screen_w;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 linda_connect(); // 接続に合わせて serial_id も取得
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 // update_screen_scope();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 SceneGraphPtr parent = sgroot->createSceneGraph();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 parent->set_move_collision(check_new_player_move, null_collision);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 create_my_sg(sgroot, parent, screen_w, screen_h);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 update_last_player_id();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 int tuple_id = NetworkGame::last_player_id * 10;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 parent->seq_rd = psx_rd(linda, tuple_id);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 sgroot->setSceneData(parent);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 return sgroot;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 NetworkGame::linda_connect() {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 init_linda(); // セレクタの初期化
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 linda = open_linda_java(linda_addr.hostname, linda_addr.port);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 // serial_id の取得
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 int seq = psx_in(linda, GET_SERIAL_ID);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 unsigned char *data = NULL;
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 do {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 psx_sync_n();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 data = psx_reply(seq);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 } while (data == NULL);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 // data[LINDA_HEADER_SIZE + psx_get_datalength(data)] = '\0';
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 serial_id = atoi((char *)data + LINDA_HEADER_SIZE);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 psx_free(data);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 printf("Get serial_id: %d\n", serial_id);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 int
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 TMmain(TaskManager *manager, int argc, char *argv[])
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 task_initialize();
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 manager->set_TMend(TMend);
1153
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
277 int xml_flag = false;
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
278
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 for (int i = 0; i < argc; i++) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 if (strcmp(argv[i],"-linda") == 0 && i + 1 <= argc) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 NetworkGame::linda_addr.hostname = argv[i+1];
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 } else if (strcmp(argv[i],"-port") == 0 && i + 1 <= argc) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 NetworkGame::linda_addr.port = atoi(argv[i+1]);
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 } else if (strcmp(argv[i],"-xml") == 0 && i + 1 <= argc) {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 NetworkGame::xml_file_name = argv[i+1];
1153
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
286 xml_flag = true;
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 }
1153
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
289 if (xml_flag) {
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
290 return init(manager, argc, argv);
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
291 } else {
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
292 perror(usr_help_str);
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
293 exit(1);
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
294 }
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
295
16c795222988 fix Makefile of Renderer/Test
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 1011
diff changeset
296 return 0;
974
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 void
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 TMend(TaskManager *manager)
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 {
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 printf("NetworkGame end\n");
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 }
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304
6e6d5a2ffe52 add OSC demo
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 /* end */