This commit is contained in:
aozhiwei 2023-04-02 10:59:13 +08:00
parent a91ac7cca8
commit a2e93d8e93
6 changed files with 13 additions and 28 deletions

View File

@ -2478,26 +2478,6 @@ void Creature::AutoNavigation(const glm::vec3& target_pos, float speed,
&xtimer_attacher);
}
void Creature::AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id)
{
trace_bullet_hash_[bullet_uniid] = std::make_tuple(target_uniid, gun_id);
room->xtimer.SetTimeoutEx
(
SERVER_FRAME_RATE * 10,
[this, bullet_uniid] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
trace_bullet_hash_.erase(bullet_uniid);
Entity* entity = room->GetEntityByUniId(bullet_uniid);
if (entity && entity->GetEntityType() == ET_Bullet) {
Bullet* bullet = (Bullet*)entity;
bullet->ForceRemove();
}
}
},
&xtimer_attacher);
}
void Creature::LockAttackDir(int time)
{
IncDisableAttackDirTimes();

View File

@ -329,7 +329,6 @@ class Creature : public MoveableEntity
void RecalcDtoAttr();
void AutoNavigation(const glm::vec3& target_pos, float speed,
std::function<void (Creature*)> cb);
void AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id);
void LockAttackDir(int time);
void PullTarget(const glm::vec3& target_pos);
void MarkSyncActivePlayer(const char* file, int line, const char* func);
@ -383,8 +382,6 @@ protected:
long long last_follow_move_frameno_ = 0;
int follow_target_last_chg_move_dir_times_ = -1;
a8::XTimerWp follow_target_timer_;
//target_uniid, gun_id
std::map<int, std::tuple<int, int>> trace_bullet_hash_;
private:
CreatureWeakPtr weak_ptr_;

View File

@ -1196,6 +1196,7 @@ void Player::_CMCancelRevive(f8::MsgHdr& hdr, const cs::CMCancelRevive& msg)
void Player::_CMRequestBulletDmg(f8::MsgHdr& hdr, const cs::CMRequestBulletDmg& msg)
{
#if 0
auto itr = trace_bullet_hash_.find(msg.bullet_uniid());
#ifdef DEBUG
a8::XPrintf("CMRequestBulletDmg bullet_uniid:%d shield_hit:%d strengthen_wall_uniid:%d target_uniid:%d found:%d\n",
@ -1262,6 +1263,7 @@ void Player::_CMRequestBulletDmg(f8::MsgHdr& hdr, const cs::CMRequestBulletDmg&
}
}
trace_bullet_hash_.erase(itr);
#endif
}
void Player::_CMRequestThrowDmg(f8::MsgHdr& hdr, const cs::CMRequestThrowDmg& msg)

View File

@ -3571,3 +3571,8 @@ bool Room::FindWalkablePointWithOutHouse(const glm::vec3& center, int try_count,
out_point = point;
return true;
}
void Room::AddReportBullet(int bullet_uniid)
{
report_bullet_hash[bullet_uniid] = GetFrameNo();
}

View File

@ -73,6 +73,8 @@ public:
int pve_human_num = 0;
PveData pve_data;
bool stop_world = false;
//target_uniid, frameno
std::map<int, long long> report_bullet_hash;
~Room();
void InitData(RoomInitInfo& init_info);
@ -219,6 +221,7 @@ public:
size_t GetRoomMaxPlayerNum();
bool RandomSafeAreaPoint(glm::vec3& point);
bool FindWalkablePointWithOutHouse(const glm::vec3& center, int try_count, int step, glm::vec3& out_point);
void AddReportBullet(int bullet_uniid);
private:
void ShuaAndroid();

View File

@ -266,10 +266,8 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
bullet_info.trace_target_uniid,
bullet_info.hand);
if (bullet_uniid && bullet_info.trace_target_uniid) {
c->AddTraceBullet(
bullet_uniid,
bullet_info.trace_target_uniid,
bullet_info.weapon_meta->id()
c->room->AddReportBullet(
bullet_uniid
);
}
} else {