修复宕机问题
This commit is contained in:
parent
f46d7dd153
commit
7302bb67ee
@ -80,6 +80,13 @@ void GridService::GetAllCellsByXy(int x, int y, std::set<GridCell*>& grid_list)
|
||||
GetAllCells(new_grid_id, grid_list);
|
||||
}
|
||||
|
||||
bool GridService::CanAdd(float x, float y)
|
||||
{
|
||||
int new_x = (int)x + cell_width_;
|
||||
int new_y = (int)x + cell_width_;
|
||||
return !BroderOverFlow(new_x, new_y);
|
||||
}
|
||||
|
||||
void GridService::AddHuman(Human* hum)
|
||||
{
|
||||
int x = (int)hum->GetX() + cell_width_;
|
||||
|
@ -25,6 +25,7 @@ class GridService
|
||||
bool BroderOverFlow(int x, int y);
|
||||
void GetAllCells(int grid_id, std::set<GridCell*>& grid_list);
|
||||
void GetAllCellsByXy(int x, int y, std::set<GridCell*>& grid_list);
|
||||
bool CanAdd(float x, float y);
|
||||
|
||||
void AddHuman(Human* hum);
|
||||
void MoveHuman(Human* hum);
|
||||
|
@ -2929,9 +2929,9 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
|
||||
|
||||
void Human::AutoChgWeapon()
|
||||
{
|
||||
if (weapons[GUN_SLOT1].weapon_idx != 0) {
|
||||
if (weapons[GUN_SLOT1].weapon_id != 0) {
|
||||
curr_weapon = &weapons[GUN_SLOT1];
|
||||
} else if (weapons[GUN_SLOT2].weapon_idx != 0) {
|
||||
} else if (weapons[GUN_SLOT2].weapon_id != 0) {
|
||||
curr_weapon = &weapons[GUN_SLOT2];
|
||||
} else {
|
||||
curr_weapon = &weapons[0];
|
||||
|
@ -578,22 +578,24 @@ int Room::CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv)
|
||||
void Room::CreateBullet(Human* hum, Weapon* weapon,
|
||||
a8::Vec2 pos, a8::Vec2 dir, float fly_distance, bool is_tank_skin)
|
||||
{
|
||||
Bullet* bullet = new Bullet();
|
||||
bullet->player = hum;
|
||||
bullet->room = this;
|
||||
bullet->gun_meta = weapon->meta;
|
||||
bullet->gun_upgrade_meta = weapon->upgrade_meta;
|
||||
bullet->meta = MetaMgr::Instance()->GetEquip(weapon->meta->i->use_bullet());
|
||||
bullet->SetPos(pos);
|
||||
bullet->dir = dir;
|
||||
bullet->born_pos = pos;
|
||||
bullet->born_dir = dir;
|
||||
bullet->fly_distance = fly_distance;
|
||||
bullet->is_tank_skin = is_tank_skin;
|
||||
bullet->entity_uniid = AllocUniid();
|
||||
bullet->Initialize();
|
||||
AddObjectLater(bullet);
|
||||
grid_service.AddBullet(bullet);
|
||||
if (grid_service.CanAdd(pos.x, pos.y)) {
|
||||
Bullet* bullet = new Bullet();
|
||||
bullet->player = hum;
|
||||
bullet->room = this;
|
||||
bullet->gun_meta = weapon->meta;
|
||||
bullet->gun_upgrade_meta = weapon->upgrade_meta;
|
||||
bullet->meta = MetaMgr::Instance()->GetEquip(weapon->meta->i->use_bullet());
|
||||
bullet->SetPos(pos);
|
||||
bullet->dir = dir;
|
||||
bullet->born_pos = pos;
|
||||
bullet->born_dir = dir;
|
||||
bullet->fly_distance = fly_distance;
|
||||
bullet->is_tank_skin = is_tank_skin;
|
||||
bullet->entity_uniid = AllocUniid();
|
||||
bullet->Initialize();
|
||||
AddObjectLater(bullet);
|
||||
grid_service.AddBullet(bullet);
|
||||
}
|
||||
}
|
||||
|
||||
void Room::RemoveObjectLater(Entity* entity)
|
||||
|
Loading…
x
Reference in New Issue
Block a user