airdrops ok
This commit is contained in:
parent
efc81d40e1
commit
30c2d8255c
@ -4,23 +4,10 @@
|
||||
|
||||
void FrameEvent::AddAirDrop(int appear_time, int box_id, Vector2D box_pos)
|
||||
{
|
||||
#if 0
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFAirDrop>* airdrops = nullptr;
|
||||
{
|
||||
{
|
||||
auto itr = frame_data.airdrops_hash.find(frame_no);
|
||||
if (itr == frame_data.airdrops_hash.end()) {
|
||||
frame_data.airdrops_hash[frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFAirDrop>();
|
||||
itr = frame_data.airdrops_hash.find(frame_no);
|
||||
}
|
||||
airdrops = &itr->second;
|
||||
}
|
||||
}
|
||||
cs::MFAirDrop* airdrop = airdrops->Add();
|
||||
cs::MFAirDrop* airdrop = airdrops_.Add();
|
||||
airdrop->set_appear_time(appear_time);
|
||||
airdrop->set_box_id(box_id);
|
||||
box_pos.ToPB(airdrop->mutable_pos());
|
||||
#endif
|
||||
}
|
||||
|
||||
void FrameEvent::AddEmote(Human* hum, int emote_id)
|
||||
@ -28,10 +15,10 @@ void FrameEvent::AddEmote(Human* hum, int emote_id)
|
||||
#if 0
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFEmote>* emotes = nullptr;
|
||||
{
|
||||
auto itr = room->frame_data.emotes_hash.find(room->frame_no);
|
||||
if (itr == room->frame_data.emotes_hash.end()) {
|
||||
room->frame_data.emotes_hash[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFEmote>();
|
||||
itr = room->frame_data.emotes_hash.find(room->frame_no);
|
||||
auto itr = room->frame_data.emotes_.find(room->frame_no);
|
||||
if (itr == room->frame_data.emotes_.end()) {
|
||||
room->frame_data.emotes_[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFEmote>();
|
||||
itr = room->frame_data.emotes_.find(room->frame_no);
|
||||
}
|
||||
emotes = &itr->second;
|
||||
}
|
||||
@ -51,10 +38,10 @@ void FrameEvent::AddShot(Human* hum)
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFShot>* shots = nullptr;
|
||||
{
|
||||
{
|
||||
auto itr = room->frame_data.shots_hash.find(room->frame_no);
|
||||
if (itr == room->frame_data.shots_hash.end()) {
|
||||
room->frame_data.shots_hash[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFShot>();
|
||||
itr = room->frame_data.shots_hash.find(room->frame_no);
|
||||
auto itr = room->frame_data.shots_.find(room->frame_no);
|
||||
if (itr == room->frame_data.shots_.end()) {
|
||||
room->frame_data.shots_[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFShot>();
|
||||
itr = room->frame_data.shots_.find(room->frame_no);
|
||||
}
|
||||
shots = &itr->second;
|
||||
}
|
||||
@ -75,10 +62,10 @@ void FrameEvent::AddBullet()
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFBullet>* bullets = nullptr;
|
||||
{
|
||||
{
|
||||
auto itr = room->frame_data.bullets_hash.find(room->frame_no);
|
||||
if (itr == room->frame_data.bullets_hash.end()) {
|
||||
room->frame_data.bullets_hash[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFBullet>();
|
||||
itr = room->frame_data.bullets_hash.find(room->frame_no);
|
||||
auto itr = room->frame_data.bullets_.find(room->frame_no);
|
||||
if (itr == room->frame_data.bullets_.end()) {
|
||||
room->frame_data.bullets_[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFBullet>();
|
||||
itr = room->frame_data.bullets_.find(room->frame_no);
|
||||
}
|
||||
bullets = &itr->second;
|
||||
}
|
||||
@ -113,10 +100,10 @@ void FrameEvent::AddSmoke(Bullet* bullet, int item_id, Vector2D pos)
|
||||
#if 0
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFSmoke>* smokes = nullptr;
|
||||
{
|
||||
auto itr = room->frame_data.smokes_hash.find(room->frame_no);
|
||||
if (itr == room->frame_data.smokes_hash.end()) {
|
||||
room->frame_data.smokes_hash[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFSmoke>();
|
||||
itr = room->frame_data.smokes_hash.find(room->frame_no);
|
||||
auto itr = room->frame_data.smokes_.find(room->frame_no);
|
||||
if (itr == room->frame_data.smokes_.end()) {
|
||||
room->frame_data.smokes_[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFSmoke>();
|
||||
itr = room->frame_data.smokes_.find(room->frame_no);
|
||||
}
|
||||
smokes = &itr->second;
|
||||
}
|
||||
@ -129,3 +116,24 @@ void FrameEvent::AddSmoke(Bullet* bullet, int item_id, Vector2D pos)
|
||||
#endif
|
||||
}
|
||||
|
||||
void FrameEvent::Clear()
|
||||
{
|
||||
if (explosions_.size() > 0) {
|
||||
explosions_.Clear();
|
||||
}
|
||||
if (smokes_.size() > 0) {
|
||||
smokes_.Clear();
|
||||
}
|
||||
if (emotes_.size() > 0) {
|
||||
emotes_.Clear();
|
||||
}
|
||||
if (bullets_.size() > 0) {
|
||||
bullets_.Clear();
|
||||
}
|
||||
if (shots_.size() > 0) {
|
||||
shots_.Clear();
|
||||
}
|
||||
if (airdrops_.size() > 0) {
|
||||
airdrops_.Clear();
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,14 @@ public:
|
||||
void AddExplosion(Bullet* bullet, int item_id, Vector2D bomb_pos);
|
||||
void AddSmoke(Bullet* bullet, int item_id, Vector2D pos);
|
||||
|
||||
void Clear();
|
||||
private:
|
||||
std::map<long long, std::set<unsigned short>> deleted_objects_hash;
|
||||
std::map<long long, std::set<unsigned short>> softdeleted_objects_hash;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFExplosion>> explosions_hash;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFSmoke>> smokes_hash;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFEmote>> emotes_hash;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFBullet>> bullets_hash;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFShot>> shots_hash;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFAirDrop>> airdrops_hash;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFExplosion> explosions_;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFSmoke> smokes_;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFEmote> emotes_;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFBullet> bullets_;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFShot> shots_;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFAirDrop> airdrops_;
|
||||
|
||||
friend class FrameMaker;
|
||||
};
|
||||
|
@ -41,14 +41,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto& pair : room->frame_data.airdrops_hash) {
|
||||
if (pair.first <= room->frame_no) {
|
||||
for (auto& itr : pair.second) {
|
||||
*msg->mutable_airdrop() = itr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -85,6 +77,9 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
hum->part_objects.erase(entity);
|
||||
}
|
||||
}
|
||||
if (room->frame_event.airdrops_.size() > 0) {
|
||||
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
|
||||
}
|
||||
if (hum->send_msg_times == 0 || hum->need_sync_active_player) {
|
||||
msg->set_active_player_id(hum->entity_uniid);
|
||||
hum->FillMFActivePlayerData(msg->mutable_active_player_data());
|
||||
@ -100,8 +95,12 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
msg->set_alive_count(room->AliveCount());
|
||||
}
|
||||
hum->new_objects.clear();
|
||||
hum->del_objects.clear();
|
||||
if (!hum->new_objects.empty()) {
|
||||
hum->new_objects.clear();
|
||||
}
|
||||
if (!hum->del_objects.empty()) {
|
||||
hum->del_objects.clear();
|
||||
}
|
||||
++hum->send_msg_times;
|
||||
return msg;
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ void Room::Update(int delta_time)
|
||||
for (auto& pair : accountid_hash_) {
|
||||
pair.second->SendUpdateMsg();
|
||||
}
|
||||
frame_event.Clear();
|
||||
}
|
||||
++frame_no;
|
||||
elapsed_time_ -= 50;
|
||||
@ -850,9 +851,6 @@ void Room::MatchTeam(Human* hum)
|
||||
void Room::InitAirDrop()
|
||||
{
|
||||
std::list<MetaData::AirDrop>& air_drops = MetaMgr::Instance()->GetAirDrops();
|
||||
#if 0
|
||||
a8::XPrintf("InitAirdrop %d %d\n", {room_uuid, air_drops.size()});
|
||||
#endif
|
||||
for (auto& air_drop : air_drops) {
|
||||
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * air_drop.i->time(),
|
||||
a8::XParams()
|
||||
@ -864,14 +862,6 @@ void Room::InitAirDrop()
|
||||
{
|
||||
Room* room = (Room*)param.sender.GetUserData();
|
||||
if (!room->game_over) {
|
||||
#if 0
|
||||
a8::XPrintf("airdrop %d %d %d\n",
|
||||
{
|
||||
param.param3,
|
||||
param.param1,
|
||||
param.param2
|
||||
});
|
||||
#endif
|
||||
room->AirDrop(param.param1, param.param2);
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user