This commit is contained in:
aozhiwei 2021-08-20 03:02:39 +00:00
parent e16548430d
commit 30a816d507
7 changed files with 58 additions and 10 deletions

View File

@ -2191,8 +2191,8 @@ void Creature::RemoveSurplusHero(int buff_id, int id, int num)
matched_heros.push_back(std::get<1>(itr));
}
}
while (matched_heros.size() >= num) {
matched_heros[0]->DetachFromMaster();
while (matched_heros.size() > num) {
matched_heros[0]->Destory();
matched_heros.erase(matched_heros.begin());
}
}
@ -2208,8 +2208,8 @@ void Creature::RemoveSurplusObstacle(int buff_id, int id, int num)
matched_things.push_back(std::get<1>(itr));
}
}
while (matched_things.size() >= num) {
matched_things[0]->DetachFromMaster();
while (matched_things.size() > num) {
matched_things[0]->Destory();
matched_things.erase(matched_things.begin());
}
}

View File

@ -344,6 +344,40 @@ void Hero::InitAI()
void Hero::OnBattleStart(Room* room)
{
if (master.Get()) {
Destory();
}
}
void Hero::Destory()
{
#if DEBUG
room->BroadcastDebugMsg(a8::Format("hero destory uniid:%d pos:%d,%d",
{
GetUniId(),
GetPos().x,
GetPos().y
}));
#endif
room->xtimer.AddDeadLineTimerAndAttach
(
0,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Hero* hero = (Hero*)param.sender.GetUserData();
if (hero->delete_frameno == 0) {
hero->BroadcastDeleteState(hero->room);
hero->RemoveFromAroundPlayers(hero->room);
hero->room->grid_service->RemoveCreature(hero);
hero->room->RemoveObjectLater(hero);
hero->delete_frameno = hero->room->GetFrameNo();
std::vector<Human*> watch_list;
hero->room->GetPartObjectWatchList(hero, watch_list);
if (!watch_list.empty()) {
abort();
}
}
},
&xtimer_attacher.timer_list_);
}

View File

@ -39,7 +39,7 @@ public:
virtual void OnAddToTargetPartObject(Entity* target) override;
virtual void OnRemoveFromTargetPartObject(Entity* target) override;
virtual void OnBattleStart(Room* room) override;
void DetachFromMaster();
void Destory();
protected:
virtual void _UpdateMove(int speed) override;
@ -47,6 +47,7 @@ protected:
virtual void RecalcSelfCollider() override;
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
void InitAI();
void DetachFromMaster();
private:
bool later_removed_ = false;

View File

@ -19,6 +19,7 @@
#include "playermgr.h"
#include "perfmonitor.h"
#include "jsondatamgr.h"
#include "skill.h"
const int kREVIVE_BUFF_ID = 1005;
@ -1244,6 +1245,12 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg)
SendDebugMsg(a8::Format("attr_id:%d abs_val:%f rate_val:%f", {attr_id, abs_val, rate_val}));
} else if (cmd == "bufflist") {
SendDebugMsg(DebugOutBuffList());
} else if (cmd == "reset_skill" && cmds.size() >= 2) {
int skill_id = a8::XValue(cmds[1]);
Skill* skill = GetSkill(skill_id);
if (skill) {
skill->Accelerate(-10000000);
}
}
}

View File

@ -2422,7 +2422,7 @@ ObstacleData* Room::GetPermanentObstacleData(int obstacle_uniid)
long long Room::GetGasInactiveTime()
{
#ifdef DEBUG
return f8::IsOnlineEnv() ? 10 : 10;
return f8::IsOnlineEnv() ? 10 : 50;
#endif
if (room_mode_ == kZombieMode) {
#if DEBUG

View File

@ -508,7 +508,7 @@ void RoomObstacle::ActiveKeepRangeBuff()
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
obstacle->DetachFromMaster();
obstacle->Destory();
},
&xtimer_attacher.timer_list_
);
@ -578,6 +578,11 @@ RoomObstacleWeakPtr& RoomObstacle::GetWeakPtrRef()
void RoomObstacle::OnBattleStart(Room* room)
{
if (master.Get()) {
Destory();
}
}
void RoomObstacle::Destory()
{
}
}

View File

@ -27,13 +27,13 @@ class RoomObstacle : public Obstacle
void ActiveTimerFunc();
void UpdateTimerFunc();
void Active();
void DetachFromMaster();
virtual void Die(Room* room) override;
Entity* GetRealObject(Room* room);
RoomObstacleWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; };
RoomObstacleWeakPtr AllocWeakPtr();
RoomObstacleWeakPtr& GetWeakPtrRef();
void Destory();
private:
void SpecExplosion();
@ -49,6 +49,7 @@ private:
void SummonAirDropBox(int box_id);
void ProcKeepRangeBuff();
void DetachFromMaster();
protected:
RoomObstacleWeakPtr weak_ptr_;