📄 auditorysystem.h
字号:
/*
Copyright (C) 2001 Tsinghuaeolus
Authors : ChenJiang, YaoJinyi, CaiYunpeng, Lishi
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
If you make any changes or have any comments we would appreciate a
message to yjy01@mails.tsinghua.edu.cn.
*/
#ifndef _audiosystem
#define _audiosystem
#include "bpn.h"
#include "types.h"
#include "Command.h"
#include "Strategy.h"
#include "RSAClass.h"
enum MsgDataType{
Msg_INT,
Msg_ShortFloat,
Msg_LongFloat
};
enum Msg_Type{
Msg_MyPlayerPos = 12,
Msg_TheirPlayerPos = 23,
Msg_BallPos = 7,
Msg_BallVel = 51,
Msg_Pass = 73,
Msg_Ballcontroller = 74,
};
class MsgData{
public:
MsgData(float data = 0, MsgDataType precision = Msg_ShortFloat){ this->data =data; this->precision = precision;}
MsgData(int data){ this->data =(float)data; this->precision = Msg_INT;}
MsgDataType precision;
float data;
void operator =(float d){ this->data = d;}
};
static char map_of_printablechar[] ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSUVWXYZ().+-*/?<>_";
class AuditoryProcess{
private:
char auditorybuffer[MAXMESG];
char saybuffer[MAXMESG];
int p_auditorybuffer;
float msgData[CP_max_msgdata];
int MsgDataNum;
int MsgNo;
//ciphertext
inline int ciphertext(char m);
inline char deciphertext(int e);
inline char map_into_printablechar(int i);
inline int demap(char m);
Time LastSpeakingTime;
public:
AuditoryProcess();
/********* AddMsg *****************************/
void AddData(MsgData msgdata);
void AddMsg(int msgNo, MsgData msgdata);
void AddMsg(int msgNo, MsgData msgdata1, MsgData msgdata2);
void AddMsg(int msgNo, MsgData msgdata1, MsgData msgdata2, MsgData msgdata3);
void AddMsg(int msgNo, MsgData msgdata1, MsgData msgdata2, MsgData msgdata3, MsgData msgdata4);
void AddMsg(int msgNo, MsgData msgdata1, MsgData msgdata2, MsgData msgdata3, MsgData msgdata4, MsgData msgdata5);
void AddMsg(int msgNo, MsgData msgdata1, MsgData msgdata2, MsgData msgdata3, MsgData msgdata4, MsgData msgdata5, MsgData msgdata6);
void AddHeader();
void ResetBuffer();
/******* ProcessMsg ************************/
void ProcessMsg(char* auditorymsg);
bool ProcessSetMsg(char **p_buffer);
/********** SendMsg ****************************/
void SendMsg();
/************ RSA ****************************/
RSAEncrypt rsa;
int encrypt(int data);
int decrypt(int data);
void encipher(char* buffer, int len);
void decipher(char* buffer, int len);
/*********** Announce **********************/
void AnnounceSelfPos();
void AnnounceMyPlayerPos(UNum NO);
void AnnounceTheirPlayerPos(UNum NO);
void AnnounceBallPos();
void AnnounceBallVel();
void AnnounceBallcontroller();
void AnnouncePass();
/*********** Hear **********************/
void HeardMyPlayerPos(UNum No, Time time);
void HeardTheirPlayerPos(UNum No, Time time);
void HeardBallPos(Time time);
void HeardBallVel(Time time);
void HeardBallcontrollers(Time time);
void HeardPass(Time time);
/*********** Strategy ****************/
bool IsCaptain(UNum NO);
bool CanSpeak();
void Communication();
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -