修复宕机问题

This commit is contained in:
aozhiwei 2020-03-20 18:23:03 +08:00
parent f46d7dd153
commit 7302bb67ee
4 changed files with 28 additions and 18 deletions

View File

@ -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_;

View File

@ -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);

View File

@ -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];

View File

@ -578,6 +578,7 @@ 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)
{
if (grid_service.CanAdd(pos.x, pos.y)) {
Bullet* bullet = new Bullet();
bullet->player = hum;
bullet->room = this;
@ -595,6 +596,7 @@ void Room::CreateBullet(Human* hum, Weapon* weapon,
AddObjectLater(bullet);
grid_service.AddBullet(bullet);
}
}
void Room::RemoveObjectLater(Entity* entity)
{