# HG changeset patch # User kazz # Date 1278653611 -32400 # Node ID c81744aaa3ef221864ab42cfa222db355756cd6d # Parent f4bdf2b0d7da1602a7da2701a9a2490b54efac8d cannot load xml of 3rd screen bug fix (include init bug yet) diff -r f4bdf2b0d7da -r c81744aaa3ef Renderer/Test/aquarium.cc --- a/Renderer/Test/aquarium.cc Tue Jul 06 23:37:11 2010 +0900 +++ b/Renderer/Test/aquarium.cc Fri Jul 09 14:33:31 2010 +0900 @@ -12,10 +12,9 @@ #define GET_SERIAL_ID 65535 -int aquarium::last_player_id = 1; +int aquarium::last_player_id = 0; Viewer *aquarium::sgroot; -SceneGraphPtr aquarium::parent; linda_t aquarium::linda_addr = { "localhost", 10000 }; int aquarium::linda; int aquarium::serial_id; @@ -43,12 +42,18 @@ } void +aquarium::update_last_player_id() { + last_player_id++; + if (last_player_id == serial_id) + last_player_id++; +} + +void aquarium::set_position(SceneGraphPtr node, unsigned char *reply) { aqua::Position *pos = new aqua::Position(); pos->ParseFromArray(reply + LINDA_HEADER_SIZE, psx_get_datalength(reply)); - node->xyz[0] = pos->x() - start_x; - node->xyz[1] = pos->y(); - printf("xyz: %f, %f\n", node->xyz[0], node->xyz[1]); + node->stack_xyz[0] = node->xyz[0] = pos->x() - start_x; + node->stack_xyz[1] = node->xyz[1] = pos->y(); delete pos; } @@ -56,7 +61,6 @@ static void update_position_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { - printf("move_xyz: %f, %f\n", node->xyz[0], node->xyz[1]); // LindaServerから座標データを取得してオブジェクトに反映させる。 if (!node->resend_flag || node->seq_rd != node->seq) { unsigned char *reply_rd = psx_reply(node->seq_rd); @@ -79,7 +83,7 @@ } SceneGraphPtr -create_sg(Viewer *viewer, SceneGraphPtr parent, unsigned char *data, int len, int serial_id) +create_sg(Viewer *viewer, SceneGraphPtr par, unsigned char *data, int len, int serial_id) { SceneGraphPtr child = viewer->sgroot->createSceneGraph(); viewer->sgroot->createFromXMLmemory(viewer->sgroot->tmanager, child, (char *)data, len); @@ -88,7 +92,7 @@ child->seq = psx_wait_rd(aquarium::linda, serial_id * 10 + 1); child->seq_rd = psx_rd(aquarium::linda, serial_id * 10 + 1); child->resend_flag = false; - parent->addChild(child); + par->addChild(child); return child; } @@ -101,9 +105,9 @@ int xml_len = psx_get_datalength(reply_rd); create_sg(aquarium::sgroot, node, xml_data, xml_len, aquarium::last_player_id); psx_free(reply_rd); - aquarium::last_player_id++; + aquarium::update_last_player_id(); int tuple_id = aquarium::last_player_id * 10; - aquarium::parent->seq_rd = psx_rd(aquarium::linda, tuple_id); + node->seq_rd = psx_rd(aquarium::linda, tuple_id); } // printf("rd id: %d\n", aquarium::last_player_id); } @@ -184,7 +188,7 @@ } void -aquarium::create_my_sg(Viewer *viewer, SceneGraphPtr parent, int screen_w, int screen_h) +aquarium::create_my_sg(Viewer *viewer, SceneGraphPtr par, int screen_w, int screen_h) { int size; void *addr = file_map(xml_file_name, &size); @@ -192,7 +196,7 @@ viewer->createFromXMLmemory(sgp, (char *)addr, size); sgp->set_move_collision(my_move, null_collision); - parent->addChild(sgp); + par->addChild(sgp); int xml_id = serial_id * 10; psx_out(linda, xml_id, (unsigned char *)addr, size); @@ -216,12 +220,12 @@ width = screen_w; linda_connect(); // 接続に合わせて serial_id も取得 update_screen_scope(); - parent = sgroot->createSceneGraph(); + SceneGraphPtr parent = sgroot->createSceneGraph(); parent->set_move_collision(check_new_player_move, null_collision); create_my_sg(sgroot, parent, screen_w, screen_h); - if (serial_id == last_player_id) - last_player_id++; + update_last_player_id(); + int tuple_id = aquarium::last_player_id * 10; parent->seq_rd = psx_rd(linda, tuple_id); sgroot->setSceneData(parent); diff -r f4bdf2b0d7da -r c81744aaa3ef Renderer/Test/aquarium.h --- a/Renderer/Test/aquarium.h Tue Jul 06 23:37:11 2010 +0900 +++ b/Renderer/Test/aquarium.h Fri Jul 09 14:33:31 2010 +0900 @@ -13,7 +13,6 @@ static int last_player_id; static Viewer *sgroot; - static SceneGraphPtr parent; static linda_t linda_addr; static int linda; static int serial_id; @@ -24,6 +23,7 @@ static void update_screen_scope(); static void send_position(SceneGraphPtr node); static void set_position(SceneGraphPtr node, unsigned char *reply); + static void update_last_player_id(); void create_my_sg(Viewer *sgroot, SceneGraphPtr parent, int screen_w, int screen_h); MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h); };