代码拉取完成,页面将自动刷新
同步操作将从 留天下/CM-Server 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "logicteam.h"
#include"networkmanager.h"
#include"messageconst.h"
DEFINE_SINGLE_ATTRIBUTES(LogicTeam);
LogicTeam::LogicTeam()
{
NET_INSTANCE()->add(MESSAGE_TEAM_APPLY,handler(this,SEL_EVENTFUNC(LogicTeam::c2sTeamApply)));
NET_INSTANCE()->add(MESSAGE_AGREE_TEAM,handler(this,SEL_EVENTFUNC(LogicTeam::c2sAgreeTeam)));
NET_INSTANCE()->add(MESSAGE_DISSOLVE_TEAM,handler(this,SEL_EVENTFUNC(LogicTeam::c2sDissolveTeam)));
NET_INSTANCE()->add(MESSAGE_REFUSE_TEAM,handler(this,SEL_EVENTFUNC(LogicTeam::c2sRefuseTeam)));
NET_INSTANCE()->add(MESSAGE_TEAM_FIGHT,handler(this,SEL_EVENTFUNC(LogicTeam::c2sTeamFight)));
NET_INSTANCE()->add(MESSAGE_TEAM_GOTO_MAP,handler(this,SEL_EVENTFUNC(LogicTeam::c2sTeamGotoMap)));
NET_INSTANCE()->add(MESSAGE_TEAM_MOVE,handler(this,SEL_EVENTFUNC(LogicTeam::c2sTeamMove)));
}
void LogicTeam::c2sTeamApply(Json::Value& msg)
{
int fd=NET_INSTANCE()->getFd();
auto& playermaps=NET_SOCKET().m_playermaps;
msg["fd"]=fd;
int dest=msg["dest"].asInt();
if(playermaps.find(dest)!=playermaps.end())
{
cout<<playermaps[fd].rolename<<" apply to make a team with "<<playermaps[dest].rolename<<endl;
NET_INSTANCE()->send(dest,MESSAGE_TEAM_APPLY,msg);
//SendMsg(msg->dest,(char*)msg,sizeof(TeamApply_Msg));
}
}
void LogicTeam::c2sRefuseTeam(Json::Value& msg)
{
int fd=NET_INSTANCE()->getFd();
auto& playermaps=NET_SOCKET().m_playermaps;
msg["fd"]=fd;
int dest=msg["dest"].asInt();
if(playermaps.find(dest)!=playermaps.end())
{
cout<<playermaps[fd].rolename<<" refused "<<playermaps[dest].rolename<<" team apply"<<endl;
NET_INSTANCE()->send(dest,MESSAGE_REFUSE_TEAM,msg);
//SendMsg(msg->dest,(char*)msg,sizeof(RefuseTeam_Msg));
}
}
void LogicTeam::c2sAgreeTeam(Json::Value& msg)
{
int fd=NET_INSTANCE()->getFd();
auto& playermaps=NET_SOCKET().m_playermaps;
msg["fd"]=fd;
int dest=msg["dest"].asInt();
if(playermaps.find(dest)!=playermaps.end())
{
cout<<playermaps[fd].rolename<<" agree "<<playermaps[dest].rolename<<" team apply"<<endl;
NET_INSTANCE()->send(dest,MESSAGE_AGREE_TEAM,msg);
// SendMsg(msg->dest,(char*)msg,sizeof(AgreeTeam_Msg));
}
}
void LogicTeam::c2sTeamMove(Json::Value& msg)
{
int fd=NET_INSTANCE()->getFd();
auto& playermaps=NET_SOCKET().m_playermaps;
msg["fd"]=fd;
int dest=msg["dest"].asInt();
if(playermaps.find(dest)!=playermaps.end())
{
cout<<playermaps[fd].rolename<<" team header move "<<playermaps[dest].rolename<<" to ("<<msg["x"].asFloat()<<","<<msg["y"].asFloat()<<")"<<endl;
NET_INSTANCE()->send(dest,MESSAGE_TEAM_MOVE,msg);
//SendMsg(msg->dest,(char*)msg,sizeof(TeamMove_Msg));
}
}
void LogicTeam::c2sTeamGotoMap(Json::Value& msg)
{
int fd=NET_INSTANCE()->getFd();
auto& playermaps=NET_SOCKET().m_playermaps;
int dest=msg["dest"].asInt();
if(playermaps.find(dest)!=playermaps.end())
{
cout<<playermaps[fd].rolename<<" team header move "<<playermaps[dest].rolename<<" to "<<msg["map"].asString()<<endl;
NET_INSTANCE()->send(dest,MESSAGE_TEAM_GOTO_MAP,msg);
//SendMsg(msg->dest,(char*)msg,sizeof(TeamGotoMap_Msg));
}
}
void LogicTeam::c2sDissolveTeam(Json::Value& msg)
{
int fd=NET_INSTANCE()->getFd();
auto& playermaps=NET_SOCKET().m_playermaps;
msg["fd"]=fd;
int dest=msg["dest"].asInt();
if(playermaps.find(dest)!=playermaps.end())
{
cout<<"Dissolve Team "<<playermaps[fd].rolename<<" and "<<playermaps[dest].rolename<<endl;
NET_INSTANCE()->send(dest,MESSAGE_DISSOLVE_TEAM,msg);
//SendMsg(msg->dest,(char*)msg,sizeof(TeamManage_Msg));
}
}
void LogicTeam::c2sTeamFight(Json::Value& msg)
{
int fd=NET_INSTANCE()->getFd();
auto& playermaps=NET_SOCKET().m_playermaps;
msg["fd"]=fd;
int dest=msg["dest"].asInt();
if(playermaps.find(dest)!=playermaps.end())
{
cout<<playermaps[fd].rolename<<" leader "<<playermaps[dest].rolename<<" entry fight"<<endl;
NET_INSTANCE()->send(dest,MESSAGE_TEAM_FIGHT,msg);
//SendMsg(msg->dest,(char*)msg,sizeof(TeamFight_Msg));
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。