This commit is contained in:
aozhiwei 2023-05-17 12:30:08 +08:00
parent 455f4ed821
commit 3acef80048
6 changed files with 86 additions and 9 deletions

View File

@ -538,6 +538,16 @@ void FrameEvent::AddPropChgEx(CreatureWeakPtr& sender, int type, int subtype,
}
}
void FrameEvent::AddEnterGame(CreatureWeakPtr& sender)
{
room->frame_event_data->enter_game_players_.push_back(sender);
}
void FrameEvent::AddExitGame(CreatureWeakPtr& sender)
{
room->frame_event_data->exit_game_players_.push_back(sender.Get()->GetUniId());
}
void FrameEvent::Clear()
{
if (!room->frame_event_data->explosions_.empty()) {
@ -597,4 +607,10 @@ void FrameEvent::Clear()
if (!room->frame_event_data->del_bullets_.empty()) {
room->frame_event_data->del_bullets_.clear();
}
if (!room->frame_event_data->enter_game_players_.empty()) {
room->frame_event_data->enter_game_players_.clear();
}
if (!room->frame_event_data->exit_game_players_.empty()) {
room->frame_event_data->exit_game_players_.clear();
}
}

View File

@ -48,6 +48,8 @@ public:
void AddPropChg(CreatureWeakPtr& sender, int type, int subtype, float value, bool only_self = false);
void AddPropChgEx(CreatureWeakPtr& sender, int type, int subtype,
float value, float value2, float value3, bool only_self = false);
void AddEnterGame(CreatureWeakPtr& sender);
void AddExitGame(CreatureWeakPtr& sender);
void Clear();
};

View File

@ -25,7 +25,10 @@ private:
std::vector<std::tuple<int, int, int>> dead_alive_objs_;
std::vector<std::tuple<CreatureWeakPtr, ::cs::MFPropertyChg>> chged_props_;
std::vector<int> del_bullets_;
std::vector<CreatureWeakPtr> enter_game_players_;
std::vector<int> exit_game_players_;
friend class FrameEvent;
friend class FrameMaker;
friend class SandTable;
};

View File

@ -15,6 +15,8 @@ namespace cs
class MFSettlement;
class MFTeamData;
class MFThrow;
class MFSandTableFullMsg;
class MFSandTablePartMsg;
class SMGameOver;
class SMUpdate;
}
@ -120,6 +122,7 @@ class Human : public Creature
float fly_distance = 0.0f;
long long send_msg_times = 0;
long long send_sand_table_msg_times = 0;
std::vector<Weapon> spec_weapons;
std::map<int, int> battlein_items;
@ -146,6 +149,8 @@ class Human : public Creature
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
virtual void FillMFObjectImage(Room* room, Human* hum, cs::MFCharacterImage* image_data) override;
virtual void FillMFPlayerStats(cs::MFPlayerStats* stats);
void FillMFSandTableFullMsg(cs::MFSandTableFullMsg* full_data);
void FillMFSandTablePartMsg(cs::MFSandTablePartMsg* part_data);
virtual float GetRadius() override;
virtual float GetHitRadius() override;
virtual bool IsDead(Room* room) override;

View File

@ -42,6 +42,7 @@
#include "smoke_mitask.h"
#include "stats.h"
#include "sandtable.h"
#include "frameeventdata.h"
#include "mt/Param.h"
#include "mt/Buff.h"
@ -796,6 +797,25 @@ void Human::FillMFPlayerStats(cs::MFPlayerStats* stats_pb)
}
}
void Human::FillMFSandTableFullMsg(cs::MFSandTableFullMsg* full_data)
{
full_data->set_obj_uniid(GetUniId());
TypeConvert::ToPb(GetPos(), full_data->mutable_pos());
TypeConvert::ToPb(GetAttackDir(), full_data->mutable_dir());
full_data->set_hero_id(meta->id());
full_data->set_team_id(team_id);
//TypeConvert::ToPb(GetAttackDir(), full_data->mutable_target_pos());
}
void Human::FillMFSandTablePartMsg(cs::MFSandTablePartMsg* part_data)
{
part_data->set_obj_uniid(GetUniId());
TypeConvert::ToPb(GetPos(), part_data->mutable_pos());
TypeConvert::ToPb(GetAttackDir(), part_data->mutable_dir());
part_data->set_team_id(team_id);
//TypeConvert::ToPb(GetAttackDir(), part_data->mutable_target_pos());
}
void Human::FillMFTeamData(Human* hum, cs::MFTeamData* team_data, bool is_game_over)
{
{
@ -2045,5 +2065,43 @@ bool PBUtils::SupportSandTable(int proto_version)
void SandTable::FillMFSandTable(cs::SMUpdate* msg, Human* hum, FrameData* framedata)
{
if (hum->send_msg_times <= 0) {
return;
}
auto sand_table = msg->mutable_sandtable();
if (hum->send_sand_table_msg_times <= 0) {
room_->TraverseHumanList
(
[sand_table] (Human* hum)
{
auto msg = sand_table->add_msgs();
msg->set_msg_id(1);
hum->FillMFSandTableFullMsg(msg->mutable_union_obj_1());
return true;
});
} else {
for (auto c : room_->frame_event_data->enter_game_players_) {
if (c.Get() && c.Get()->IsHuman()) {
auto msg = sand_table->add_msgs();
msg->set_msg_id(1);
hum->FillMFSandTableFullMsg(msg->mutable_union_obj_1());
}
}
room_->TraverseHumanList
(
[sand_table] (Human* hum)
{
auto msg = sand_table->add_msgs();
msg->set_msg_id(2);
hum->FillMFSandTablePartMsg(msg->mutable_union_obj_2());
return true;
});
for (int obj_uniid : room_->frame_event_data->exit_game_players_) {
auto msg = sand_table->add_msgs();
msg->set_msg_id(3);
msg->mutable_union_obj_3()->set_obj_uniid(obj_uniid);
}
}
++hum->send_sand_table_msg_times;
}

View File

@ -1219,6 +1219,7 @@ message MFSandTableFullMsg
optional MFVec3 dir = 3; //
optional int32 hero_id = 4; //id
optional int32 team_id = 5; //Id
optional MFVec3 target_pos = 6; //
}
//-
@ -1228,6 +1229,7 @@ message MFSandTablePartMsg
optional MFVec3 pos = 2; //
optional MFVec3 dir = 3; //
optional int32 team_id = 4; //Id
optional MFVec3 target_pos = 6; //
}
//-
@ -1236,13 +1238,6 @@ message MFSandTableRemoveObject
optional int32 obj_uniid = 1; //id
}
//-
message MFSandTableMoveTo
{
optional int32 obj_uniid = 1; //id
optional MFVec3 pos = 2; //
}
//
message MFSandTableMsg
{
@ -1250,14 +1245,12 @@ message MFSandTableMsg
1:
2
3
4:
*/
optional int32 msg_id = 1; //id
optional MFSandTableFullMsg union_obj_1 = 2;
optional MFSandTablePartMsg union_obj_2 = 3;
optional MFSandTableRemoveObject union_obj_3 = 4;
optional MFSandTableMoveTo union_obj_4 = 5;
}
//