gridservice addhuman ok

This commit is contained in:
aozhiwei 2019-04-24 16:49:16 +08:00
parent 5120480f41
commit 9dfdb4952d
3 changed files with 18 additions and 13 deletions

View File

@ -1,6 +1,7 @@
#include "precompile.h"
#include "gridservice.h"
#include "human.h"
GridService::GridService()
{
@ -103,9 +104,19 @@ void GridService::Get369(int grid_id, std::set<GridCell*>& grid_list)
GetGridList(grid_id, 9, grid_list);
}
void GridService::AddHuman(Human* hum, std::set<GridCell*>& inc_grid_list)
void GridService::AddHuman(Human* hum)
{
int x = (int)hum->pos.x + cell_width_;
int y = (int)hum->pos.y + cell_width_;
if (BroderOverFlow(x, y)) {
abort();
}
hum->grid_id = x/cell_width_ + (y/cell_width_) * cell_count_per_row_;
if (hum->grid_id == 0 || hum->grid_id > max_grid_id_) {
abort();
}
cells_[hum->grid_id].human_list.insert(hum);
Get123456789(hum->grid_id, hum->grid_list);
}
void GridService::MoveHuman(Human* hum, float x, float y,

View File

@ -34,7 +34,7 @@ class GridService
void Get258(int grid_id, std::set<GridCell*>& grid_list);
void Get369(int grid_id, std::set<GridCell*>& grid_list);
void AddHuman(Human* hum, std::set<GridCell*>& inc_grid_list);
void AddHuman(Human* hum);
void MoveHuman(Human* hum, float x, float y,
std::set<GridCell*>& inc_grid_list,
std::set<GridCell*>& dec_grid_list

View File

@ -169,11 +169,8 @@ void Room::AddPlayer(Player* hum)
accountid_hash_[hum->account_id] = hum;
human_hash_[hum->entity_uniid] = hum;
++alive_count_;
{
std::set<GridCell*> inc_grid_list;
grid_service.AddHuman(hum, inc_grid_list);
hum->RefreshView();
}
grid_service.AddHuman(hum);
hum->RefreshView();
MatchTeam(hum);
}
@ -211,11 +208,8 @@ void Room::ShuaAndroid()
moveable_hash_[hum->entity_uniid] = hum;
human_hash_[hum->entity_uniid] = hum;
++alive_count_;
{
std::set<GridCell*> inc_grid_list;
grid_service.AddHuman(hum, inc_grid_list);
hum->RefreshView();
}
grid_service.AddHuman(hum);
hum->RefreshView();
}
}