1
This commit is contained in:
parent
0b66e7d927
commit
bcf9fa317a
@ -964,5 +964,13 @@ void Player::_CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg)
|
||||
|
||||
void Player::_CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg)
|
||||
{
|
||||
|
||||
cs::SMWatchWar respmsg;
|
||||
Human* target = room->GetWatchWarTarget(this);
|
||||
if (target) {
|
||||
SendNotifyMsg(respmsg);
|
||||
target->FollowTarget(target);
|
||||
} else {
|
||||
respmsg.set_error_code(1);
|
||||
SendNotifyMsg(respmsg);
|
||||
}
|
||||
}
|
||||
|
@ -592,6 +592,21 @@ bool Room::OverBorder(const Vector2D pos, float radius)
|
||||
return false;
|
||||
}
|
||||
|
||||
Human* Room::GetWatchWarTarget(Human* hum)
|
||||
{
|
||||
std::vector<Human*> humans;
|
||||
for (auto& pair : human_hash_) {
|
||||
if (pair.first != hum->entity_uniid) {
|
||||
humans.push_back(pair.second);
|
||||
}
|
||||
}
|
||||
if (!humans.empty()) {
|
||||
Human* target = humans[rand() % humans.size()];
|
||||
return target;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Room::NewTeam()
|
||||
{
|
||||
++current_teamid;
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
|
||||
void OnHumanDie(Human* hum);
|
||||
bool OverBorder(const Vector2D pos, float radius);
|
||||
Human* GetWatchWarTarget(Human* hum);
|
||||
|
||||
private:
|
||||
unsigned short AllocUniid();
|
||||
|
@ -662,7 +662,7 @@ message CMWatchWar
|
||||
//观战error_code == 0 时关闭结算界面,回到战斗界面
|
||||
message SMWatchWar
|
||||
{
|
||||
optional int32 error_code = 1; //错误码
|
||||
optional int32 error_code = 1 [default = 0]; //错误码 0:成功 1:失败
|
||||
optional string error_msg = 2; //错误信息
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user