修复空袭预警coredump问题

This commit is contained in:
aozhiwei 2021-11-04 17:20:56 +08:00
parent ea68294f62
commit 3129b7ff54
5 changed files with 47 additions and 8 deletions

View File

@ -69,6 +69,27 @@ void MapService::UnInit()
}
bool MapService::CanAdd(const a8::Vec2& pos, int rad)
{
//上
if (pos.y + rad + 10 > map_height_) {
return false;
}
//下
if (rad + 10 > pos.y) {
return false;
}
//左
if (rad + 10 > pos.x) {
return false;
}
//右
if (pos.x + rad + 10 > map_width_) {
return false;
}
return true;
}
void MapService::AddCollider(ColliderComponent* collider)
{
if (!(collider->owner->IsEntityType(ET_Obstacle) ||

View File

@ -38,6 +38,7 @@ class MapService
void UnInit();
void AddCollider(ColliderComponent* collider);
bool CanAdd(const a8::Vec2& pos, int rad);
void RemoveCollider(ColliderComponent* collider);
void GetColliders(Room* room,
float world_x,

View File

@ -4010,3 +4010,13 @@ void Room::AddTeam(class MatchTeam* team)
}
NotifyUiUpdate();
}
bool Room::CanAddObstacle(const a8::Vec2& pos, int obstacle_id)
{
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(obstacle_id);
if (!thing_meta) {
return false;
}
int rad = std::max(thing_meta->i->width(), thing_meta->i->height());
return map_service->CanAdd(pos, rad);
}

View File

@ -227,6 +227,7 @@ public:
void SetInfiniteBulletMode();
bool IsInfiniteBulletMode() { return infinite_bullet_mode_; };
void AddToPostBattleAutoFreeList(xtimer_list* timer);
bool CanAddObstacle(const a8::Vec2& pos, int obstacle_id);
private:
void ShuaAndroid();

View File

@ -720,15 +720,21 @@ void RoomObstacle::InstallPreExplostionSummonTimer()
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
RoomObstacle* p = obstacle->room->CreateObstacle
(
param.param1,
a8::Vec2 pos = a8::Vec2(
obstacle->GetPos().x + param.param2.GetDouble(),
obstacle->GetPos().y + param.param3.GetDouble()
);
if (obstacle->room->CanAddObstacle(pos, param.param1)) {
RoomObstacle* p = obstacle->room->CreateObstacle
(
param.param1,
pos.x,
pos.y
);
if (p) {
p->Active();
}
}
},
&xtimer_attacher.timer_list_
);