📄 parse.cpp
字号:
#include "world.h"#include "parse.h"#include "common.h"#include "Geometry.h"#include "body.h"#include <string>#include <vector>#include <sstream>#include <iostream>using namespace std;#include "common.h"void analyze_server_message( string &msg, world*wm, body *bd ){ for(int i=0;i<msg.length();i++) if(msg[i]=='(' || msg[i]==')') msg[i]=' '; istringstream iss(msg); string type,t,name; double ax1,ax2,p; double x, y, z; int a, b; while(iss>>type) { if(type=="time") { iss>>t>>p; //cout<<t<<"--> "<<p<<endl; wm->simulation_time = p; }if(type=="GS") { iss>>t; if(t=="unum") { iss>>a>>t>>name; wm->uniform_number=a; wm->team_side=name; //cout<<name<<endl; wm->set_flags(); wm->set_teammate(a,Vector3d(0,0,0)); } iss>>p>>t>>name; //cout<<p<<"--> "<<t<<"--> "<<name<<endl; wm->game_time = p; wm->play_mode = play_mode_name_to_enum(name); } else if(type=="F1L" || type=="F2L" || type=="F1R" || type=="F2R" || type=="G1L" || type=="G2L" || type=="G1R" || type=="G2R") { iss>>t>>x>>y>>z; //cout<<t<<"--> "<<x<<"--> "<<y<<"--> "<<z<<endl; wm->flags[flag_name_to_number(type)].vision_position = Vector3d(x,y,z,POLAR); } else if(type=="B") { iss>>t>>x>>y>>z; wm->ball_vision_position = Vector3d(x,y,z,POLAR); } else if(type=="P") { iss>>t>>name>>t>>a>>t>>x>>y>>z; if(name==wm->team_name) wm->set_teammate(a,Vector3d(x,y,z,POLAR)); else wm->set_opponent(a,Vector3d(x,y,z,POLAR)); } else if(type=="HJ") { iss>>t>>name>>t>>ax1; joint_name_to_number(name,a,b); bd->j[a].previous_angle=bd->j[a].angle; bd->j[a].previous_update_time=bd->j[a].update_time; bd->j[a].angle = ax1; bd->j[a].update_time = wm->simulation_time; } else if(type=="GYR") { iss>>name>>name>>name>>x>>y>>z; wm->SetGyro(x,y,z); } else if(type=="hear") { string HearMsg,HearName; iss>>p>>HearName; do { iss>>name; HearMsg+=name; }while(name!="GYR"); wm->SetHearMsg(p,HearName,HearMsg); } else if(type=="TCH") ; else if(type=="FRP") ; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -