serializerplayerstdv8.cpp
来自「2009 ROBOCUP 仿真2DSERVER 源码」· C++ 代码 · 共 319 行
CPP
319 行
// -*-c++-*-/*************************************************************************** serializerplayerstdv8.cpp Class for serializing data to std v8 players ------------------- begin : 27-MAY-2002 copyright : (C) 2002 by The RoboCup Soccer Server Maintenance Group. email : sserver-admin@lists.sourceforge.net***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/#include "serializerplayerstdv8.h"#include "player.h"namespace rcss {SerializerPlayerStdv8::SerializerPlayerStdv8( const SerializerCommon & common ) : SerializerPlayerStdv7( common ){}SerializerPlayerStdv8::~SerializerPlayerStdv8(){}constSerializerPlayerStdv8 *SerializerPlayerStdv8::instance(){ rcss::SerializerCommon::Creator cre; if ( ! rcss::SerializerCommon::factory().getCreator( cre, 8 ) ) { return NULL; } static SerializerPlayerStdv8 ser( cre() ); return &ser;}voidSerializerPlayerStdv8::serializeVisualPlayer( std::ostream & strm, const Player & player, const std::string & name, const double & dist, const int dir ) const{ strm << " (" << name << ' ' << dist << ' ' << dir; if ( player.isTackling() ) strm << " t"; strm << ')';}voidSerializerPlayerStdv8::serializeVisualPlayer( std::ostream & strm, const Player & player, const std::string & name, const double & dist, const int dir, const int point_dir ) const{ strm << " (" << name << ' ' << dist << ' ' << dir << ' ' << point_dir; if ( player.isTackling() ) strm << " t"; strm << ')';}voidSerializerPlayerStdv8::serializeVisualPlayer( std::ostream & strm, const Player & player, const std::string & name, const double & dist, const int dir, const double & dist_chg, const double & dir_chg, const int body_dir, const int head_dir ) const{ strm << " (" << name << ' ' << dist << ' ' << dir << ' ' << dist_chg << ' ' << dir_chg << ' ' << body_dir << ' ' << head_dir; if ( player.isTackling() ) strm << " t"; strm << ')';}voidSerializerPlayerStdv8::serializeVisualPlayer( std::ostream & strm, const Player & player, const std::string & name, const double & dist, const int dir, const double & dist_chg, const double & dir_chg, const int body_dir, const int head_dir, const int point_dir ) const{ strm << " (" << name << ' ' << dist << ' ' << dir << ' ' << dist_chg << ' ' << dir_chg << ' ' << body_dir << ' ' << head_dir << ' ' << point_dir; if ( player.isTackling() ) strm << " t"; strm << ')';}voidSerializerPlayerStdv8::serializeAllyAudioFull( std::ostream & strm, const int time, const double & dir, const int unum, const char* msg ) const{ strm << "(hear " << time << ' ' << dir << " our " << unum << " \"" << msg << "\")";}voidSerializerPlayerStdv8::serializeOppAudioFull( std::ostream & strm, const int time, const double & dir, const char* msg ) const{ strm << "(hear " << time << ' ' << dir << " opp \"" << msg << "\")";}voidSerializerPlayerStdv8::serializeAllyAudioShort( std::ostream & strm, const int time, const int unum ) const{ strm << "(hear " << time << " our " << unum << ')';}voidSerializerPlayerStdv8::serializeOppAudioShort( std::ostream & strm, const int time ) const{ strm << "(hear " << time << " opp)";}voidSerializerPlayerStdv8::serializeFSBall( std::ostream & strm, const double & x, const double & y, const double & vel_x, const double & vel_y ) const{ strm << " ((b)" << ' ' << x << ' ' << y << ' ' << vel_x << ' ' << vel_y << ')';}voidSerializerPlayerStdv8::serializeFSPlayerBegin( std::ostream & strm, const char side, const int unum, const bool goalie, const int type, const double & x, const double & y, const double & vel_x, const double & vel_y, const double & body_dir, const double & neck_dir ) const{ strm << " ((p " << side << ' ' << unum; if ( goalie ) { strm << " g"; } else { strm << ' ' << type; // hetro player type } strm << ") " << x << ' ' << y << ' ' << vel_x << ' ' << vel_y << ' ' << body_dir << ' ' << neck_dir;}voidSerializerPlayerStdv8::serializeFSPlayerArm( std::ostream & strm, const double & mag, const double & head ) const{ strm << ' ' << mag << ' ' << head;}voidSerializerPlayerStdv8::serializeFSPlayerStamina( std::ostream & strm, const double & stamina, const double & effort, const double & recovery, const double & /*stamina_capacity*/ ) const{ strm << " (stamina " << stamina << ' ' << effort << ' ' << recovery << ')';}voidSerializerPlayerStdv8::serializeFSCounts( std::ostream & strm, const int count_kick, const int count_dash, const int count_turn, const int count_catch, const int count_move, const int count_turn_neck, const int count_change_view, const int count_say ) const{ strm << " (count " << count_kick << ' ' << count_dash << ' ' << count_turn << ' ' << count_catch << ' ' << count_move << ' ' << count_turn_neck << ' ' << count_change_view << ' ' << count_say << ')';}voidSerializerPlayerStdv8::serializeServerParamBegin( std::ostream & strm ) const{ strm << "(server_param ";}voidSerializerPlayerStdv8::serializePlayerParamBegin( std::ostream & strm ) const{ strm << "(player_param ";}voidSerializerPlayerStdv8::serializePlayerTypeBegin( std::ostream & strm ) const{ strm << "(player_type ";}voidSerializerPlayerStdv8::serializeParam( std::ostream & strm, const std::string & name, const int param ) const{ strm << "(" << name << ' ' << param << ')';}voidSerializerPlayerStdv8::serializeParam( std::ostream & strm, const std::string & name, const bool param ) const{ strm << "(" << name << ' ' << param << ')';}voidSerializerPlayerStdv8::serializeParam( std::ostream & strm, const std::string & name, const double & param ) const{ strm << "(" << name << ' ' << param << ')';}voidSerializerPlayerStdv8::serializeParam( std::ostream & strm, const std::string & name, const std::string & param ) const{ strm << "(" << name << " \"" << param << "\")";}namespace {constSerializerPlayer *create(){ return SerializerPlayerStdv8::instance();}RegHolder v8 = SerializerPlayer::factory().autoReg( &create, 8 );RegHolder v9 = SerializerPlayer::factory().autoReg( &create, 9 );RegHolder v10 = SerializerPlayer::factory().autoReg( &create, 10 );RegHolder v11 = SerializerPlayer::factory().autoReg( &create, 11 );RegHolder v12 = SerializerPlayer::factory().autoReg( &create, 12 );}}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?