修改sendupdatemsg消息发送时机 子弹扣血问题

This commit is contained in:
aozhiwei 2020-06-02 14:31:11 +08:00
parent c88e463f97
commit 7dd91deffb
6 changed files with 15 additions and 9 deletions

View File

@ -40,9 +40,6 @@ void Android::Update(int delta_time)
}
}
InternalUpdate(delta_time);
if (room->GetFrameNo() % 2 == 0) {
SendUpdateMsg();
}
++updated_times_;
}

View File

@ -65,6 +65,7 @@ void Bullet::OnHit(std::set<Entity*>& objects)
float def = hum->ability.def * (1 + hum->GetBuffAttrRate(kHAT_Def)) +
hum->GetBuffAttrAbs(kHAT_Def);
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
finaly_dmg = std::max(finaly_dmg, 0.0f);
player->stats.damage_amount_out += finaly_dmg;
hum->DecHP(finaly_dmg, player->GetEntityUniId(), player->name, gun_meta->i->id());
#ifdef DEBUG

View File

@ -25,9 +25,9 @@ class Entity
virtual bool IsDead(Room* room) { return false;};
virtual long long GetDeadFrameNo(Room* room) { return 0;};
virtual void OnPreCollision(Room* room) {};
int GetEntityUniId() { return entity_uniid_; }
EntityType_e GetEntityType() { return entity_type_; }
EntitySubType_e GetEntitySubType() { return entity_subtype_; }
int GetEntityUniId() const { return entity_uniid_; }
EntityType_e GetEntityType() const { return entity_type_; }
EntitySubType_e GetEntitySubType() const { return entity_subtype_; }
virtual bool IsEntityType(EntityType_e type) { return type == entity_type_;}
virtual bool IsEntitySubType(EntitySubType_e subtype) { return subtype == entity_subtype_;}
int GetGridId() const { return grid_id_; }

View File

@ -38,7 +38,15 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
auto& tuple = room->frame_event.shots_[idx];
if (hum->CanSee(std::get<0>(tuple))) {
*msg->add_shots() = std::get<1>(tuple);
} else {
#ifdef DEBUG
abort();
#endif
}
} else {
#ifdef DEBUG
abort();
#endif
}
}
for (size_t idx : hum->bullets_) {

View File

@ -46,9 +46,6 @@ void Player::Update(int delta_time)
}
}
InternalUpdate(delta_time);
if (room->GetFrameNo() % 2 == 0) {
SendUpdateMsg();
}
++updated_times_;
}

View File

@ -117,6 +117,9 @@ void Room::Update(int delta_time)
pair.second->Update(50);
}
if (GetFrameNo() % 2 == 0) {
for (auto& pair : human_hash_) {
pair.second->SendUpdateMsg();
}
frame_event.Clear();
}
++frameno_;