Advertisement
Ladies_Man

ccg reading scheme old

Nov 29th, 2015
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. 4
  2. c
  3. 1337 150 300 10
  4. 1488 -1
  5. b
  6. 1488 200 700 0
  7. 1337 322 0 -1
  8. b
  9. 322 300 500 10
  10. 1488 0 -1 633
  11. c
  12. 633 300 150 30
  13. 322 -1
  14. stop
  15.  
  16.  
  17.  
  18. for (i = 0; i < num; i++) {
  19.         char el_type[6];
  20.         printf("type:");
  21.         fscanf(fp, "%s", el_type);
  22.  
  23.         if (0 == strcmp(el_type, "stop"))
  24.             break;
  25.  
  26.         node *curr_node;
  27.         int pos_x, pos_y, mass;
  28.         int body_name, conn_left_name, conn_right_name, conn_top_name, conn_bot_name;
  29.        
  30.         if (0 == strcmp(el_type, "block") || 0 == strcmp(el_type, "b")) {
  31.  
  32.             printf("name pos_x pos_y mass:");
  33.             fscanf(fp, "%d%d%d%d", &body_name, &pos_x, &pos_y, &mass);
  34.             printf("connection: L R T B:");
  35.             fscanf(fp, "%d%d%d%d", &conn_left_name, &conn_right_name, &conn_top_name, &conn_bot_name);
  36.  
  37.             list->append_back(body_name);
  38.             curr_node = list->get_by_id(body_name);
  39.             curr_node->set_list_param('b', body_name, i, pos_x, pos_y, mass);
  40.            
  41.             printf("block:%d[x:%d y:%d m:%d CL:%d CR:%d CT:%d CB:%d] has been added.\n\n", body_name, pos_x, pos_y, mass, conn_left_name, conn_right_name, conn_top_name, conn_bot_name);
  42.         }
  43.  
  44.         if (0 == strcmp(el_type, "cargo") || 0 == strcmp(el_type, "c")) {
  45.  
  46.             printf("name pos_x pos_y mass:");
  47.             fscanf(fp, "%d%d%d%d", &body_name, &pos_x, &pos_y, &mass);
  48.             printf("connection: T B:");
  49.             fscanf(fp, "%d%d", &conn_top_name, &conn_bot_name);
  50.  
  51.             list->append_back(body_name);
  52.             curr_node = list->get_by_id(body_name);
  53.             curr_node->set_list_param('c', body_name, i, pos_x, pos_y, mass);
  54.  
  55.             printf("cargo:%d[x:%d y:%d m:%d CT:%d CB:%d] has beed added.\n\n", body_name, pos_x, pos_y, mass, conn_top_name, conn_bot_name);
  56.         }
  57.  
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement